-
Notifications
You must be signed in to change notification settings - Fork 71
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
[feature request] Adding boolean query method #240
Comments
I agree with you that |
Sure, let's use a common ground for easier discussion, consider the following elasticsearch query: {
"query": {
"bool": {
"must": [
{
"dis_max": {
"queries": [
{
"match": {
"title": {
"query": "sea whale",
"boost": 2
}
}
},
{
"match": {
"body": {
"query": "white dog",
"boost": 1.5
}
}
}
],
"tie_breaker": 0.3
}
}
]
}
}
} The current For class Query:
...
@staticmethod
def boolean_query(subqueries: Iterator[tuple[Occur, Query]]) -> Query:
... This requires the introduction of Occur The above elasticsearch syntax can be then transformed to: Query.boolean_query(
[
(
Occur.MUST,
Query.dis_max_query(
[
Query.phrase_query("title", "sea whale", boost=2),
Query.phrase_query("body", "white dog", boost=1.5)
],
tie_breaker=0.3
)
)
]
) which providers 3 benefits to developers:
|
Thanks for taking the time to write it out. You've explained it well 👍🏼 We are currently tracking progress on wrapping these query types in this comment in #20. I see |
Added pull request for the implementation #243 |
PR has been merged, thanks! |
The existing boolean query feature could be done from the
index.parse_query
, as long as we type the correct characters like+
,-
formust
andmust_not
respectively.However, there could be cases that users would like to create their inner query dynamically, or for the sake readability that they would like a container for their other query types like
FuzzyTermQuery
andPhraseQuery
.Currently the rust
tantivy
package allows creating the boolean query from theStruct tantivy::query::BooleanQuery
. Willtantivy-py
also have theboolean_query
staticmethod for theQuery
class?The text was updated successfully, but these errors were encountered: