Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Solr - OR in filter query

Tags:

apache

solr

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 possible to use OR instead of AND?

like image 735
krinn Avatar asked Sep 29 '11 09:09

krinn


People also ask

What is filter query in Solr?

The fq filter query parameter in a query to Solr search is used to filter out some documents from the search result without influencing the score of the returned documents. Queries with fq parameters are cached.

How do you write a query in Solr?

Trying a basic queryThe main query for a solr search is specified via the q parameter. Standard Solr query syntax is the default (registered as the “lucene” query parser). If this is new to you, please check out the Solr Tutorial. Adding debug=query to your request will allow you to see how Solr is parsing your query.

Which is better Solr or Elasticsearch?

Solr has more advantages when it comes to the static data, because of its caches and the ability to use an uninverted reader for faceting and sorting – for example, e-commerce. On the other hand, Elasticsearch is better suited – and much more frequently used – for timeseries data use cases, like log analysis use cases.


1 Answers

You can use

fq=cat:(computers OR phones) 
like image 192
Jayendra Avatar answered Oct 01 '22 08:10

Jayendra