In our search application, I want to allow users to combine their previous search results using AND/OR. Basically combine the results of previously executed queries. How can I achieve this in SOLR?
Asked
Active
Viewed 751 times
0
-
1Hi Soma, kindly show us what you tried so far and what goes wrong with this. Read http://stackoverflow.com/help/how-to-ask before asking your next question. – J. Chomel Jul 20 '16 at 07:11
-
That depends on how you're querying. In general, just wrapping both queries within `()` and with `AND` or `OR` between them should work. What have you tried? – MatsLindh Jul 20 '16 at 11:12
-
We have 2 queries as follows which we need to merge results: – Soma Jul 27 '16 at 05:01
-
Example of the 2 queries: 1. Get the articles in the journal 'Animal Sciences' for latest issue. – Soma Jul 27 '16 at 05:44
-
Query 2: Get the articles with key word 'Cow diseases'. I need to merge the results with AND / OR between this query and the previous one. – Soma Jul 27 '16 at 05:45
1 Answers
0
If those previous queries affect ranking. If they do affect ranking (can be partial match), you need to combine them together in a main query. There can be only one main query, though it can have subqueries in other variables passed through local parameters.
However, if they are binary (match/not match) queries, such as for categories/filters/facets, then you can use Filter Queries (fq) instead. Those you can have several and each one basically reduces matches without affecting ranking.

Alexandre Rafalovitch
- 9,709
- 1
- 24
- 27
-
Thanks. These are not filter queries, rather two different queries whose results need to be merged – Soma Jul 27 '16 at 05:40