Skip to content

Conversation

@sergio-bobillier
Copy link
Collaborator

Changes the QueryBuilder::QueryClauses::Bool class to allow it to accept nested boolean queries.

The main driver behind this change is the need to combine must and should clauses with a particular precedence when querying multiple indexes, especially when some of the fields in the query exist in only a subset of those indexes.

@sergio-bobillier sergio-bobillier self-assigned this Oct 17, 2025
@sergio-bobillier sergio-bobillier force-pushed the sb-JAY-678-nested-boolean branch 2 times, most recently from 084376b to 999704e Compare October 20, 2025 08:46
Copy link
Collaborator

@sheputis sheputis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, does this leave the 'not' behaviour consistent? it does not break anything?

Changes the QueryBuilder::QueryClauses::Bool class to allow it to accept
nested boolean queries.

The main driver behind this change is the need to combine 'must' and
'should' clauses with a particular precedence when querying multiple
indexes, especially when some of the fields in the query exist in only a
subset of those indexes.
@sergio-bobillier
Copy link
Collaborator Author

question, does this leave the 'not' behaviour consistent? it does not break anything?

Well, the negation works by wrapping whatever you currently have into a bool with a single must_not subclause. It doesn't care what's inside. That basically flips around whatever is inside, including nested booleans. Regarding the "consistency" of the resulting clause, well I cannot say for sure that depends on how Elasticsearch interprets the resulting clause.

But that is probably beyond the scope of Jay API. I.e. it cannot be stuffed with extra logic to fix the inconsistencies of Elasticsearch (if there are actually any).

@sergio-bobillier sergio-bobillier force-pushed the sb-JAY-678-nested-boolean branch from 999704e to 4f9445b Compare October 21, 2025 08:00
@sheputis
Copy link
Collaborator

question, does this leave the 'not' behaviour consistent? it does not break anything?

Well, the negation works by wrapping whatever you currently have into a bool with a single must_not subclause. It doesn't care what's inside. That basically flips around whatever is inside, including nested booleans. Regarding the "consistency" of the resulting clause, well I cannot say for sure that depends on how Elasticsearch interprets the resulting clause.

But that is probably beyond the scope of Jay API. I.e. it cannot be stuffed with extra logic to fix the inconsistencies of Elasticsearch (if there are actually any).

Ah, just to clarify — I didn’t mean for you to verify Elasticsearch’s behavior :)
I was referring specifically to Jay API.

I always forget the exact details of how the query builder is structured (it’s a bit complex), and I remember we’ve had regressions in the not handling before. So my question was just to double-check whether you had that in mind when making the change.

@sergio-bobillier
Copy link
Collaborator Author

I always forget the exact details of how the query builder is structured (it’s a bit complex), and I remember we’ve had regressions in the not handling before. So my question was just to double-check whether you had that in mind when making the change.

No worries. I appreciate you raising the question. I actually went into the code to check what was actually happening. It did not occur to me that the negation could break. So thanks for bringing that up. 🤝

@sergio-bobillier sergio-bobillier merged commit 5a965e4 into master Oct 21, 2025
2 checks passed
@sergio-bobillier sergio-bobillier deleted the sb-JAY-678-nested-boolean branch October 21, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants