1

I'm using Solr 3.6 version and in one of my query I need to apply Query and filter Query for some requirement.

Scenario - I want to search one keyword under particular search criteria so I'm putting my keyword as 'q' in Solr Query and applying search criteria as 'fq'.

  1. is there any way, we can apply multiple criteria / Filter Query for particular search ?

q: "Keyword" fq: "context"

  1. also can we have OR operation between those criteria ? i.e. Bring me all results matching my "Keyword" from "criteria 1" OR "criteria 2"?

Thanks in advance. Devendra

Enigma
  • 749
  • 1
  • 13
  • 35

1 Answers1

1

is there any way, we can apply multiple criteria / Filter Query for particular search ?

You can simply pass fq multiple times, and results will be filtered. In fact this is a recommended approach for performance -- filters are very heavily cached. Example:

 &fq=field:val&fq=field2:val&q=Keyword

also can we have OR operation between those criteria ? i.e. Bring me all results matching my "Keyword" from "criteria 1" OR "criteria 2"?

If you want to view the results for your query where either criteria 1 OR criteria 2 are true, you can simply use Lucene Query Syntax in your filter query, which allows for boolean operators

 &fq=criteria:1 OR criteria:2&q=Keyword
Doug T.
  • 64,223
  • 27
  • 138
  • 202
  • We are grammatically building query to get get data from FIELD CACHE. and don't know how to fire with multiple filter queries ? Can you please suggest. – Enigma Feb 20 '14 at 06:23
  • Found out it ----> fq=context:(q1 OR q2) – Enigma Feb 20 '14 at 11:15