-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create a boolean query with both "should" and "must" clauses? #258
Comments
For reference, here is my configuration:
|
Wondering if someone here can help 🙏 |
extend base class get_queryset() and define your own queries there, rather than using search-filter-backends
You will have finer control over your queries with this |
This question comes up regularly. I'll add it to the FAQ, but TL;DR: If you need a combination of ANDs and ORs, use SimpleQueryStringSearchFilterBackend. Check for examples here and in docs. |
Questions
Hi @barseghyanartur. First, thanks for this great package. It has been extremely useful.
I was unable to find an answer to my question in the docs or by examining the source code so I figured I'd take a look.
Basically, what I need to do is generate a boolean query where one part of it is in a
must
clause and the other is in ashould
. More specifically, the query I would like to generate is as such:The reason for the above is to boost a phrase match.
With that being said, whenever I try mixing the following backends:
What ends up happening is that my term query ends up in a must clause even though I specify
matching="should"
pretty much everywhere.I even debugged this all the way to
base.py
where I confirmedmatching="should"
yet somehow the final query ends up all in the "must".Any ideas what I'm doing wrong?
The text was updated successfully, but these errors were encountered: