0

I want to search data in multiple category,

Steps -

  1. If I search a keyword on my website it will show results that matches on all category.
  2. Then I will choose multiple category filter from which categories results I want.

My Solr query as below which is not showing any results when I click on multicheckbox.

How to query on solr with multiple value ?

I have checked Function Query and Logical operators as well but nothing seems to be working now.

Query Example 1 -

http://localhost:8983/solr/shop_core/select?indent=on&q=(title_search_t:*hunter*+OR+description_t:*hunter*)+AND+((fq=parent_category_i:(2103+OR+2105)+OR+fq=child_1_category_i:(2103+OR+2105))+OR+(fq=parent_category_i:(2103+OR+2105)+OR+fq=child_2_category_i:(2103+OR+2105))+OR+(fq=parent_category_i:(2103+OR+2105)+OR+fq=child_3_category_i:(2103+OR+2105)))&wt=json&sort=qty_d+DESC+&sort=is_in_stock_i+DESC+&sort=id+ASC&rows=10000

Query Example 2-

http://localhost:8983/solr/shop_core/select?indent=on&q=(title_search_t:*hunter*+OR+description_t:*hunter*)
+AND+(parent_category_i:(2110+AND+2105)+OR+child_1_category_i:(2110+AND+2105))+OR+(parent_category_i:(2110+AND+2105)+OR+child_2_category_i:(2110+AND+2105))+OR+(parent_category_i:(2110+AND+2105)+OR+child_3_category_i:(2110+AND+2105))&wt=json&sort=qty_d+DESC+&sort=is_in_stock_i+DESC+&sort=id+ASC&rows=10000

Any help would be appreciated.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
Rahul
  • 763
  • 1
  • 12
  • 45
  • `parent_category_i:(2110+AND+2105)` - are you actually looking for documents have both parent categories? `parent_category_i:(2110 OR 2105)` seems more natural? In your first example you're including `fq` inside your query - that's a separate URL parameter, so it'd be `&q=... ...&fq=`. It's also important to be aware that each `fq` will _filter_ the results, so they always limit the set of documents being returned - they never expand it - so you can't OR different `fq` parameters - they'd represent different filters in your facets (for example category, price, color, etc.). – MatsLindh Oct 21 '20 at 11:45
  • I want combine results for both category ids(multiple values), they can be present in any parameter like parent_category_i, child_1_category_i, child_2_category_i so on.. What can be correct query on above requirement – Rahul Oct 21 '20 at 11:59
  • `parent_category_i:(123 OR 321) OR child_1_category_i:(123 OR 321) OR .. ` should do that if you want area where they're present in either field. – MatsLindh Oct 21 '20 at 12:21
  • I want results that category id should present in either area like in parent, child etc. I want union result where category id can be present in any field. – Rahul Oct 25 '20 at 06:18
  • Then what I wrote should do what you need. – MatsLindh Oct 25 '20 at 11:16

0 Answers0