I just built a search form backed by Solr, we are using the solarium library to construct our requests.
We built a "huge" collection of filterqueries like that one:
$query = $client->createQuery($client::QUERY_SELECT);
$query->setStart(0)->setRows(1000);
$query->addFilterQuery($query->createFilterQuery("foo")->setQuery("bar:true"));
$query->addFilterQuery($query->createFilterQuery("fo")->setQuery("ba:false"));
....
But we realized that the search just hits all the single fields we specify in the filterqueries, but we have to actually query multiple fields.
While reading the docs I realized we could have been wrong, right? The correct approach would be to use disMax queries (in combination with facets?)?
I'm wondering, can we use DisMax in combination with filterqueries to "expand" our search to multiple fields (with boosts)? or do we have to actually rework everything?
I'm kinda missing the big picture to decide what the best/working solution would be.
Help is much appreciated.
Edit:
Solr:
solr-spec 7.6.0
Solarium:
solarium/solarium 6.0.1 PHP Solr client
You can give a query parser when giving the fq
argument:
fq={!dismax qf="firstfield secondfield^5"}this is my query
The syntax is known as Local Parameters. Since dismax
(or edismax
which you should normally use now) doesn't have a identifier in front of it, it is implicitly parsed as the type.
If a local parameter value appears without a name, it is given the implicit name of "type". This allows short-form representation for the type of query parser to use when parsing a query string.
You'll have to make sure that Solarium doesn't escape the value you give to setQuery
, but seeing as you're already giving a field:value
combination, it doesn't seem to get escaped. Double check the Solr log to see exactly what query is being sent to Solr (or ask Solarium to give you the exact query string being sent if possible).