简体   繁体   English

Apache Solr - 过滤查询中的OR

[英]Apache Solr - OR in filter query

Is it possible to search (with apache Solr) for items which are in one of few categories using filter query, eg items in category 'computers' OR 'phones' 是否可以使用过滤查询搜索(使用apache Solr)少数类别之一的项目,例如“计算机”或“电话”类别中的项目

When I want to search for items in category computers AND phones I type: 当我想在类别计算机和手机中搜索项目时,我输入:

select/?q=...&fq=cat:computers&fq=cat:phones

but it is possible to use OR instead of AND ? 但是可以使用OR代替AND吗?

您可以使用

fq=cat:(computers OR phones)

A filter query is just a query -- as complex as you'd like. 过滤查询只是一个查询 - 就像您想要的那样复杂。 So, you can certainly build up a query, eg, 所以,你当然可以建立一个查询,例如,

fq=(cat1:val1 OR cat2:val2 OR (cat3:(val3 AND val4)))

...or whatever. ...管他呢。

The only difference between a filter query and a plain-old query (besides memory and caching issues, which you might want to also think about) is that a filter query doesn't affect the relevancy scores at all. 筛选器查询和普通旧查询之间的唯一区别(除了您可能还想考虑的内存和缓存问题)是筛选器查询根本不会影响相关性分数。 But in terms of complexity, you can do whatever you want. 但就复杂性而言,你可以做任何你想做的事。

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

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