This is perhaps best discussed on the java-user list instead. Here's some thoughts...

On Jun 4, 2010, at 2:36 AM, Li Li wrote:

hi all,
  I want to implement a query that taking position and terms'
relative positions into consideration. It only supports multiterm
queries like boolean or query.
  But I want to consider term postion and terms relative positions.
  e.g. there are two docs
 doc1         apache lucene is a open source project
 doc2         apache is a http server and lucene ...
 if user search "apache lucene"  doc1 will win because apache lucene
appear closer than doc2

A PhraseQuery will do that. It's common-place to OR in a (sloppy) phrase query for the users query in order to get proximity to boost things. No custom query needed to accomplish this.

 e.g.
 doc1        some other text apache lucene is a open source project
 doc2         apache lucene is a open source project some other text
 doc2 wins because "apache lucene" appear at the first position

And here, SpanFirstQuery is your friend. So OR'ing a PhraseQuery and a SpanFirstQuery (with nested SpanNearQuery, or whatever is appropriate) seems to accomplish your goals.

Give those a try and report back if things still aren't quite what you're after.

        Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to