How can I use Solr subquery similar to rdbms subqueries?

Nazanin picture Nazanin · May 28, 2015 · Viewed 7k times · Source

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?

Answer

Abhijit Bashetti picture Abhijit Bashetti · May 28, 2015

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)