Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to OR two joins in Solr

I have the following statement:

({!join from=project_uuid to=id}type:EM_PM_Timerecord AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z]) OR ({!join from=project_uuid to=id}type:EM_CM_Request_Member AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z])

It doesn't return any documents, but if I use only one of the joins e.g.:

{!join from=project_uuid to=id}type:EM_PM_Timerecord AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z]

It returns some documents.

If I remove the date ranges it works as well:

({!join from=project_uuid to=id}type:EM_PM_Timerecord) OR ({!join from=project_uuid to=id}type:EM_CM_Request_Member)

Can someone tell me what I'm missing? And what is wrong with the first statement?

Thanks in advance.

EDIT

In debug the parsed query looks like this:

(+JoinQuery({!join from=project_uuid to=id}type:EM_PM_Timerecord) +created:[1420074000000 TO 1451610000000]) (+JoinQuery({!join from=project_uuid to=id}type:EM_CM_Request_Member) +created:[1420074000000 TO 1451610000000])

And maybe I should mention that I use it as a filter query, but as far as i understand it that should not make a difference in the result.

like image 734
Mathias Mahlknecht Avatar asked Oct 27 '25 03:10

Mathias Mahlknecht


1 Answers

I asked now in the SolrUsers mailing list as recommended and I got an answer.

The query has to be split up in multiple queries like this:

&q={!join from=project_uuid to=id v=$q1} OR {!join from=project_uuid to=id v=$q2} 
&q1=type:EM_PM_Timerecord AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z] 
&q2=type:EM_CM_Request_Member AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z] 

and it works fine.

My problem was that I put the whole thing under &q=... and apparently that was to much.

like image 123
Mathias Mahlknecht Avatar answered Oct 30 '25 00:10

Mathias Mahlknecht



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!