Rajath
Rajath

Reputation: 215

Is there a way where we could do phrase proximity search using the lucene core libraries

I need to perform a proximity search between few phrases. The number of phrases are not known before hand. User can enter any number of phrases and can give his own slop. I need to support the nested phrase proximity search queries too. For example of the search queries I am looking at is: "letter comes" slop "agitated employees". "letter comes" slop "agitated employees" slop "worried about salaries". "letter comes" slop "agitated slop "phrase1 slop phrase2 slop phrase3" slop empl"

Upvotes: 0

Views: 804

Answers (2)

RocketScience
RocketScience

Reputation: 42

This patch by Tim Allison will help your use case. It provides recursive phrase queries and some other functionalities too.

Upvotes: 1

Mark Leighton Fisher
Mark Leighton Fisher

Reputation: 5693

As far as I know, you cannot perform nested proximity searches. A kludge might be to create a phrase combining all terms with a large slop, say the sum of the individual slops:

("letter comes"~3 "agitated employees"~4 "worried about salaries"~1)
 AND ("letter comes agitated employees worried about salaries"~8)

(above assumes that your default operator is OR). I would play around with the combination phrase slop to see if I could get close to what I want.

Upvotes: 1

Related Questions