简体   繁体   English

SOLR Solarium 我们可以将过滤器查询与 dismax 查询一起使用吗?

[英]SOLR Solarium can we use filter-queries with dismax-queries?

i just built a search form backed by solr, we are using the solarium library to construct our requests.我刚刚构建了一个由 solr 支持的搜索表单,我们正在使用日光浴室库来构建我们的请求。

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?)?正确的方法是使用 disMax 查询(结合构面?)? im wondering, can we use DisMax in combination with filterqueries to "expand" our search to multiple fields (with boosts)?我想知道,我们是否可以将 DisMax 与 filterqueries 结合使用以将我们的搜索“扩展”到多个字段(带有提升)? or do we have to actually rework everything?还是我们必须实际返工所有内容?

im kinda missing the big picture to decide what the best/working solution would be我有点错过了决定最佳/可行解决方案的大局

help is much appreciated非常感谢帮助

edit:编辑:

solr: 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参数时提供查询解析器:

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.由于dismax (或您现在通常应该使用的edismax )前面没有标识符,因此它被隐式解析为类型。

If a local parameter value appears without a name, it is given the implicit name of "type".如果局部参数值出现时没有名称,它会被赋予隐式名称“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.您必须确保 Solarium 不会转义您给setQuery的值,但是由于您已经提供了一个field:value组合,所以它似乎没有转义。 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).仔细检查 Solr 日志以查看发送到 Solr 的确切查询(或者如果可能的话请 Solarium 为您提供发送的确切查询字符串)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM