3

I need to run a query in Solr that contains another query as terms of the main query!

Something like this in the RDBMS SQL:

select name from movie
where movie.writer in (
    select director from movie where producer = 'XXX'
)

Is there any way to do this is Solr?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nazanin
  • 53
  • 1
  • 6

2 Answers2

1

Solved.
This is possible using "join" in Solr.
Following is the solution for my answered example:

fl=name&  
q={!join from=writer to=director}+producer:XXX

Also a filter query can be added. This filter will affect the result of join and query.
Thanks to Ramzy.

Nazanin
  • 53
  • 1
  • 6
0

you can try filter, something like this..

q=movie:name
fq=(writer:writer_name AND producer:Producer_name)

also the data that you put into a Solr index is flat or denormalized. So take the suquery field values and put them in an AND part of the query to Solr.

q=(movie:name AND writer:Writer_name AND producer:Producer_name)
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
  • In the example, I want to retreive movies that their writer is the director of movies that "XXX" produces! A simple "and" filrer can't result such list. – Nazanin May 28 '15 at 06:32
  • I'm searching for a way to implement my query as a one phase query, however I implemented it with two phases queries (putting the result of inner query in the main query). – Nazanin May 28 '15 at 06:39
  • I would like to how you tried and whats the result? whats the document structure you have ? – Abhijit Bashetti May 28 '15 at 10:45