Thanks for reply, but won't BooleanQuery return both doc1 and doc2 with query:
label:States AND label:America AND label:United Best, Jin On Tue, Aug 19, 2014 at 2:07 PM, Tri Cao <tm...@me.com> wrote: > given that example, the easy way is a boolean AND query of all the terms: > > > http://lucene.apache.org/core/4_6_0/core/org/apache/lucene/search/BooleanQuery.html > > However, if your corpus is more sophisticated you'll find that relevance > ranking is not always that trivial :) > > On Aug 19, 2014, at 11:00 AM, Jin Guang Zheng <zhen...@rpi.edu> wrote: > > Hi, > > I am wondering if someone can help me on this: > > I have index: > > doc 1 -- label: United States of America > > doc 2 -- label: United > doc 2 -- label: America > doc 2 -- label: States > > I am wondering how to generate a query with terms: states united america > > so only doc 1 returns. > > > I was thinking SpanNearQuery, but can't make it work. > > Thanks, > Jin > >