Search code examples
solrsolr-query-syntax

solr query: x out of n words matched


supposedly I have 4 words (let's call them a,b,candd for sake of example) and I want to search in solr to match 3 of these. I could write a query with all the permutations as follows:

(a AND b AND c)OR(a AND b AND d)OR(b AND c and d)

This will work and matches documents with 3 of these 4 words.

but things get messy when I have 10 words and need to match 3 of them. The number of permutations required grows exponentially.

obviously thanks to the complexity of the query solr goes busted(it gets too slow to respond)

I've searched all over internet to find out if there is a special command I could use for something like this. I couldn't find anything. I'm just wondering if there is any tricks that could be done to accomplish something like this.


Solution

  • Have a look at the mm parameter of the eDisMax parser.