How to query for a word in Solr ignoring a combination with it?

Viewed 55

I have a working Solr with a lot of documents in it. My problem is that I don't find a way to query for a specific word like Switzerland, but don't want to find documents containing the combination Saxon Switzerland except they contain Switzerland without the preceding Saxon.

A similar question already got asked here on SO, but the solution to query Switzerland -"Saxon Switzerland" would not work as the documents containing both would be missing.

I don't want to exclude the phrase, but ignore it for matching. But it seems that there is no possibility to partially negate or ignore a phrase or proximity search. Is there any possibility to search for something like Switzerland {ignore}"Saxon Switzerland"? Or can you exclude phrases from matching at all? (only for a single query as the phrase might be of interest for other queries)

1 Answers

To ignore "saxon" From "Switzerland"

Try below Query . text:'NOT(saxon) AND Switzerland'

Above will provide output only Switzerland only not with "saxon Switzerland"

Thanks Soni

Related