Lucene BooleanClause setMinimumNumberShouldMatch
When we use BoooleanQuery, we will use it if we want to hit at least N of them.SetMinimumNumberShouldMatch method.
For example:
BooleanQuery bq = new BooleanQuery (); bq. add (new TermQuery (new Term ("title", "java"), BooleanClause. occur. shocould); bq. add (new TermQuery (new Term ("title", "C #"), BooleanClause. occur. shocould); bq. add (new TermQuery (new Term ("title", "javascript"), BooleanClause. occur. shocould); bq. add (new TermQuery (new Term ("title", "php"), BooleanClause. occur. shocould); bq. setMinimumNumberShouldMatch (3 );
The query string is: (title: java title: C # title: javascript title: php )~ 3
When we use this string as the q Parameter of solr for retrieval, solr will prompt us with a syntax error. However, we sometimes have to use this feature. For example, I want to recruit at least three persons (just an example) for java, C #, js, and php ), you need to use
SolrEdismax
When searching, we select defType = edismax mm = 3, and mm indicates at least the number of BooleanClause to be satisfied.