Solr - subqueries

join, solr, subquery

Solution

joins are there since solr 3.4. Check this out

http://lucidworks.com/blog/lucene_3_4_0/

Problem

I need to do a Solr sub-query, which if it was in MySQL would look like so: ``` SELECT * FROM solr_index WHERE type = 'person' AND city IN (SELECT name FROM solr_index WHERE name = 'London' AND type = 'city') ``` Apparently Solr Joins are very similar - http://wiki.apache.org/solr/Join. But these are only available in Solr 4 it seems. Is there some way I can do this in Solr 3.X ? Ideally a way compatible with the ComplexPhraseQueryParser and that the Solr PHP Client or Solarium have support for. Any help is greatly appreciated. UPDATE: Another example which is not location related: ``` SELECT * FROM solr_index WHERE type = 'project' AND tag IN (SELECT name FROM solr_index WHERE name = 'Elephant' AND type = 'tag') ```

Original source