In lucene3 How do I retrieve data from colA = colB?
Data:
ID colA colB
1 a b
2 a a
3 b c
4 b b
Required results:
ID colA colB
2 a a
4 b b
Lucene does not currently have out-of-the-box support for join queries.
Most solutions would involve doing two queries and merging the results yourself. Implicit join in lucene sheds some light on potential solutions. However, none of these solutions are likely to very performant.
On the other hand, if you have the ability to use Solr on top of Lucene, the dev version of Solr (4.0) has just recently added join functionality (see https://issues.apache.org/jira/browse/SOLR-2272)
With the Solr solution, you could easily satisfy your use-case by querying for the following:
fq={!join from=colA to=colB}