Skip to content

Conversation

@nik9000
Copy link
Member

@nik9000 nik9000 commented Jun 11, 2025

Fixes the ESQL's detection of constant_keyword fields. We unplugged it when we changed a function signature because we didn't have an @Override annotation. This plugs it back in and adds it to the integration tests we use for pushing queries to lucene. When you do | WHERE constant_keyword_field == "itsvalue" then the whole is removed from the query plan because all documents are equal.

Fixes the ESQL's detection of `constant_keyword` fields. We unplugged it
when we changed a function signature because we didn't have an
`@Override` annotation. This plugs it back in and adds it to the
integration tests we use for pushing queries to lucene. When you do
`| WHERE constant_keyword_field == "itsvalue"` then the whole is removed
from the query plan because *all* documents are equal.
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @nik9000, I've created a changelog YAML for you.


@Override
public String toString() {
return "LocalSourceOperator";
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix the signature rendering for the test.

case "match_only_text", "semantic_text" -> true;
ComputeSignature dataNodeSignature = switch (type) {
case "auto", "constant_keyword", "text" -> ComputeSignature.FILTER_IN_QUERY;
case "match_only_text", "semantic_text" -> ComputeSignature.FILTER_IN_COMPUTE;
Copy link
Member Author

Choose a reason for hiding this comment

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

Because I was changing a bunch of stuff I put these in alphabetical order while I went. We're going to keep adding stuff to this in the next few months, I think. So sorted order helps.

String val = null;
for (SearchExecutionContext ctx : contexts) {
MappedFieldType f = ctx.getFieldType(name);
MappedFieldType f = ctx.getFieldType(name.string());
Copy link
Member Author

Choose a reason for hiding this comment

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

Real fix is all in this file.

Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM

@nik9000
Copy link
Member Author

nik9000 commented Jun 11, 2025

I'm going to add keyword to the test case here - not because we need it for this but because @julian-elastic needs it for another thing he's working on and I have this file open.

Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Ooh, this is such a nice test improvement. Thanks a lot @nik9000 !

@nik9000
Copy link
Member Author

nik9000 commented Jun 12, 2025

oooh conflicts! working

@nik9000 nik9000 enabled auto-merge (squash) June 12, 2025 12:21
@nik9000 nik9000 merged commit 4cda8c2 into elastic:main Jun 12, 2025
17 of 18 checks passed
@alex-spies
Copy link
Contributor

@nik9000 , I think we forgot the auto-backport-and-merge label; or did you plan to backport manually?

@nik9000
Copy link
Member Author

nik9000 commented Jun 12, 2025

Ah, yeah. I thought I had put backport-pending. It's running locally now

nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Jun 12, 2025
Fixes the ESQL's detection of `constant_keyword` fields. We unplugged it
when we changed a function signature because we didn't have an
`@Override` annotation. This plugs it back in and adds it to the
integration tests we use for pushing queries to lucene. When you do
`| WHERE constant_keyword_field == "itsvalue"` then the whole is removed
from the query plan because *all* documents are equal.
@nik9000
Copy link
Member Author

nik9000 commented Jun 12, 2025

Backport: #129354

elasticsearchmachine pushed a commit that referenced this pull request Jun 16, 2025
* ESQL: Fix constant keyword optimization (#129278)

Fixes the ESQL's detection of `constant_keyword` fields. We unplugged it
when we changed a function signature because we didn't have an
`@Override` annotation. This plugs it back in and adds it to the
integration tests we use for pushing queries to lucene. When you do
`| WHERE constant_keyword_field == "itsvalue"` then the whole is removed
from the query plan because *all* documents are equal.

* Old lucene is different
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants