0

I recently changed the schema of our Solr cluster and now indexing documents in the nested structure. I have indexed restaurant as parent with its dish as child docs. BJQ (Block Join Query) parent query parser is handy to filter out all the parents for the child satisfying a given condition -

{!parent which=doc_type:restaurant}doc_type:dish AND dish_name:burger

So the above query returns all the restaurant having burger as one of the dish. I have a use case where I want to filter out all the restaurant having multiple dishes all at once e.g restaurant selling burger & fries both.

{!parent which=doc_type:restaurant}doc_type:dish AND (dish_name:burger OR dish_name:fries)

above query will return restaurants selling either of burger or fries.

Its seems tedious to filter out restaurants selling both using BJQ. How can I write query to achieve this?

leandrojmp
  • 7,082
  • 2
  • 19
  • 24
Saurav Kumar Singh
  • 1,352
  • 7
  • 18

1 Answers1

0

An approach I'v found uses {!bool}

q={!bool
 must="{!parent which=doc_type:restaurant}(+doc_type:dish +dish_name:burger)" 
 must="{!parent which=doc_type:restaurant}(+doc_type:dish +dish_name:fries)"
}

If you want to use multivalue references, please note that this does not work correctly in case of block join.

Use single value references as workaround

q={!bool must=$ref1 must=$ref2}
&ref1={!parent which=doc_type:restaurant}+doc_type:dish +dish_name:burger
&ref2={!parent which=doc_type:restaurant}+doc_type:dish +dish_name:fries
tia_ru
  • 1