Reputation: 413
In Lucene's proximity search the order of the words searched is not maintained.
Is there any way to filter the search so that word1 will always come before word2 in resulted docs.
Upvotes: 0
Views: 132
Reputation: 5246
There is the SpanNearQuery
for that.
SpanTermQuery tq1 = new SpanTermQuery(new Term("field", "word1"));
SpanTermQuery tq2 = new SpanTermQuery(new Term("field", "word2"));
SpanNearQuery spanNear = new SpanNearQuery(new SpanQuery[]{tq1,tq2}, 2, true);
Upvotes: 1