user1662409
user1662409

Reputation: 157

phrase synonym analyser Lucene.net?

I am using the Synonym Analyser, but this only adds synonyms for single words. Is there a similar analyser for phrases or does anyone know any other way of adding phrase synonyms? For example, "The Big Apple" should return a hit for "New York".

Thanks.

Upvotes: 3

Views: 589

Answers (1)

Bart Czernicki
Bart Czernicki

Reputation: 3693

You can obviously build your own analyzer...I built a synonym analyzer that took single words and matched multiple words...custom development.

Instead of doing that, I would recommend dynamically injecting synonyms during query building or parsing. For example, you could have a person search for "The Big Apple"... 1) check the phrase "The Big Apple" for synonym phrases 2) If synonym phrases exist, build a boolean query with 2 PhraseQueries "The Big Apple" and "New York".

Another (more performant way) is to use MultiPhraseQueries instead of boolean PhraseQueries. This would depend on how complex your boolean queries get...I have found both work pretty fast in my case.

Down side of this is that it will be a bit slower on search. The benefit is that it is completely dynamic and doesn't require index rebuilds if you configure/change synonyms. It is also perfect if you have a multi-tenant solution where each client can have different synonyms.

Upvotes: 2

Related Questions