How can I do a proximity search for two multi-word phrases in Lucene. For example, I want to find all
black lab* (black labrador, black labradoodle, etc) withing 5 words of the phrase “pet shop”. Which analyzer should I be using? Which query parser would be recommended? I’m working with Lucene.NET. I’ve ported the ComplexPhraseQueryParser from Java to C#, but that parser doesn’t seem to be doing the trick (or perhaps I’m just using it wrong). I’m just getting started with Lucene, so your help is much appreciated.
How can I do a proximity search for two multi-word phrases in Lucene. For
Share
You can use a SpanQuery for this:
The default Lucene
QueryParserdoesn’t support span queries, but you could try the Surround query parser. I couldn’t find much else in the way of documentation.You may also find this answer and this blog post useful.