Is it possible to search (with apache Solr) for items which are in one of few categories using filter query, e.g. items in category 'computers' OR 'phones'
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 pos开发者_开发技巧sible to use OR
instead of AND
?
You can use
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, e.g.,
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.
精彩评论