|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-01-08 11:43 UTC] xavier dot schepler at sciences-po dot fr
Description:
------------
It seems that attributes from the first SolrQuery object are presents in the second SolrQuery object attributes.
Reproduce code:
---------------
<?php
$solrClient = new SolrClient(parse_ini_file('bdq/bdq/application/configs/solr.ini'));
$solrQuery = new SolrQuery;
$solrQuery->setQuery('l?gislative');
$response = $solrClient->query($solrQuery);
$solrQuery->setShowDebugInfo(true);
$solrQuery->setHighlight(true);
$solrQuery->addHighlightField('questionsLabelsFr');
$solrQuery->addHighlightField('variableLabelsFr');
$solrQuery->setHighlightFragsize(0);
var_dump($response);
$solrQuery = new SolrQuery;
$solrQuery->setQuery('l?gislative');
$solrQuery->setShowDebugInfo(true);
$solrQuery->setHighlight(true);
$solrQuery->addHighlightField('questionsLabelsFr');
$solrQuery->addHighlightField('variableLabelsFr');
$solrQuery->setHighlightFragsize(0);
$response = $solrClient->query($solrQuery);
var_dump($response);
Expected result:
----------------
I expected the same results from both queries.
Actual result:
--------------
Here are extracts from the SolrQueryResponse objects dumps :
- First response :
protected 'http_raw_request' => string 'q=l%E9gislative'
- Second response :
protected 'http_raw_request' => string 'q=l%E9gislativeq=l%E9gislative&debugQuery=true&hl=true&hl.fl=questionsLabelsFr%2CvariableLabelsFr&hl.fragsize=0' (length=111)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
The difference in results is as a result of a logic error in the php code. The first call sends only 1 parameter. The second call sends 6 parameters. <?php $solrClient = new SolrClient(parse_ini_file('bdq/bdq/application/configs/solr.ini')); $solrQuery = new SolrQuery; $solrQuery->setQuery('l?gislative'); // At this point only the 1 parameter has been set $response = $solrClient->query($solrQuery); $solrQuery->setShowDebugInfo(true); $solrQuery->setHighlight(true); $solrQuery->addHighlightField('questionsLabelsFr'); $solrQuery->addHighlightField('variableLabelsFr'); $solrQuery->setHighlightFragsize(0); var_dump($response); $solrQuery = new SolrQuery; $solrQuery->setQuery('l?gislative'); $solrQuery->setShowDebugInfo(true); $solrQuery->setHighlight(true); $solrQuery->addHighlightField('questionsLabelsFr'); $solrQuery->addHighlightField('variableLabelsFr'); $solrQuery->setHighlightFragsize(0); // At this point 6 parameters have been set. $response = $solrClient->query($solrQuery); var_dump($response);You're right about the logic error. It was late in the day and I couldn't concentrate to give you a proper example. I'm at home and I have not solr installed ATM. Does it work this way ? <?php $solrClient = new SolrClient(parse_ini_file('bdq/bdq/application/configs/solr.ini')); $solrQuery = new SolrQuery; $solrQuery->setQuery('l?gislative'); $solrQuery->setShowDebugInfo(true); $solrQuery->setHighlight(true); $solrQuery->addHighlightField('questionsLabelsFr'); $solrQuery->addHighlightField('variableLabelsFr'); $solrQuery->setHighlightFragsize(0); $response = $solrClient->query($solrQuery); var_dump($response); $solrQuery = new SolrQuery; $solrQuery->setQuery('l?gislative'); $solrQuery->setShowDebugInfo(true); $solrQuery->setHighlight(true); $solrQuery->addHighlightField('questionsLabelsFr'); $solrQuery->addHighlightField('variableLabelsFr'); $solrQuery->setHighlightFragsize(0); $response = $solrClient->query($solrQuery); var_dump($response);