Hello Anna.
Agreed. It's a little bit counterintuitive, but described explicitly in the
braced note here
https://lucene.apache.org/core/9_7_0/core/org/apache/lucene/search/BooleanQuery.Builder.html#setMinimumNumberShouldMatch(int)

To achieve what you need

> set to 0, meaning that all
clauses are optional.

  you can combine the dismax with match all query *:*

On Thu, Jan 4, 2024 at 4:43 PM Anna Ruggero <a.rugg...@sease.io> wrote:

> Hi everyone,
>
> I have this query that uses the Boolean Query Parser:
> *http://localhost:8983/solr/books/select
> <http://localhost:8983/solr/books/select>?*
> *q={!bool filter=$**categoryIds** should=$queryTerms}&*
> *categoryIds**=**category:(1 2 5 7)**&*
> *queryTerms=**content**:(user text)*
>
> I would like to achieve the same result using the eDisMax query parser, but
> I encountered some problems with the minimum should match clause.
>
> Here is the query:
> *http://localhost:8983/solr/books/select
> <http://localhost:8983/solr/books/select>?*
> *fq=category:(1 2 5 7)&*
> *q=user text&*
> *df=content&*
> *defType=edismax*
>
> It returns only documents having "*user"* or "*text"* in the content field
> (but at least one of them is needed). If no documents contain those words
> in the *content* field, I have zero results returned.
> From the debug, I could see that the parsed query is:
> *+(DisjunctionMaxQuery((**content**:user)) DisjunctionMaxQuery((**content*
> *:text)))*
>
> By default the minimum should match parameter is set to 0, meaning that all
> clauses are optional. Why is there the + operator before the two
> disjunction queries? I wouldn't expect to see it. I would expect to see all
> documents returned even if none of them match any term in q.
>
> Also, if I explicitly set mm to 1 like:
> *http://localhost:8983/solr/books/select
> <http://localhost:8983/solr/books/select>?*
> *fq=category:(1 2 5 7)&*
> *q=user text&*
> *df=content&*
> *defType=edismax&*
> *mm=1*
>
> The parsed query is:
> *+(DisjunctionMaxQuery((**content**:**user**)) DisjunctionMaxQuery((*
> *content**:**text*
> *)))~1*
> Whose meaning is the same as the query before (with mm=0).
>
> What is the difference between mm=0 and mm=1?
>
>
> Thank you!
>
> *Anna Ruggero*
> R&D Machine Learning / Software Engineer, Search Consultant
> e-mail: a.rugg...@sease.io
>
>
> *Sease* - Information Retrieval Applied
> Consulting | Training | Open Source
> Sease.io <http://sease.io/>
> LinkedIn <https://linkedin.com/company/sease-ltd> | Twitter
> <https://twitter.com/seaseltd> | Youtube
> <https://www.youtube.com/channel/UCDx86ZKLYNpI3gzMercM7BQ> | Github
> <https://github.com/seaseltd>
>


-- 
Sincerely yours
Mikhail Khludnev

Reply via email to