Hi,

I'm more or less new to Solr. I need to run queries that use joins all over the place. (The idea is to index database records pretty much as they are and then query them in interesting ways and, most importantly, get the rank. Our dataset is not too large so the performance is great.)

I managed to express the logic using the following approach. For example, I want to search people by their names or addresses:

  q=type:Person^=0 AND ({!edismax qf=<personFields> v=$p0} OR {!join <personToAddress> v=$p1})
  p1={!edismax qf=<addressFields> v=p0}
  p0=<queryText>

(Here 'type:Person' works as a filter so I zero its score.) This seems to work as expected and give the right results and ranking. It also seems to scale nicely for two levels of joins, although the queries become rather hard to follow in their raw form (I used a custom XML-to-query transformer to actually formulate more complex queries).

So my question is that: can I express an equivalent query using the query DSL? I know I can use 'bool' like that:

{
  "query": {
     "bool" : {
        "must" : [ ... ];
        "should" : [ ... ]
      }
   }
 }

But how do I actually go from 'x AND (y OR z)' to 'bool' in the query DSL? I seem to lose the nice compositional properties of the expression. Here, for example, the expression implies that at least 'y' or 'z' must match; I don't quite see how I can express this in the DSL.

Kind regards,
Mikhail

Reply via email to