Closed wassafr closed 7 years ago
this was an bug in solr. should be fixed.
I think your fix broke something. With the exact same code I don't get any result anymore, $pois is always empty.
What is the result when you run the query without addField
?
Same result, it doesn’t return anything.
Please add $query->setUseWildcard(false);
and run the query again.
For extra debugging information start tail -f app/logs/dev.log | grep solr
. You can see something like solr.INFO: run request: select?omitHeader=true&wt=json&json.nl=flat&q=title_s:"relation 1"&start=0&rows=10&fl=id [] []
(in your case something like name_s:"foo" instead of title_s)
Run the query in your solr-admin to make sure that your index contains data.
Working with $query->setUseWildcard(false);
.
By looking at the log, I can only see one difference when using wildcard between the bundle and running the query directly in Solr admin : the bundle generate title_s:"*relation 1*"
while the Solr admin generate title_s:*relation 1*
(no double quotes).
The latter works while the first doesn't.
Which version do you use? The double quotes issue was fixed in https://github.com/floriansemm/SolrBundle/commit/439ed223861f1dadcc6396b1d433ad21d4462484 which is part of the last release.
I use the latest version 1.3.2. In the commit you talk about, you added the double quotes. That's precisely my problem because if I remove them from your code, it's working perfectly.
Finally, not using wildcard is not an option for me because I need have results that only match substrings of the fields.
@wassafr Is the problem still existent?
I've followed the example of the README to have only one field to be mapped :
$search = $request->get('search_query');
$query = $this->get('solr.client')->createQuery('WassaIndoorWayfindingAdminBundle:Poi'); $query->addSearchTerm('name', $search); $query->setHydrationMode(HydrationModes::HYDRATE_INDEX); $query->addField('id'); $pois = $query->getResult();
foreach ($pois as $poi) { echo $poi->getMapId(); // Display the real value whilst the doc says it should be empty }