Skip to content

Conversation

@pmpailis
Copy link
Contributor

@pmpailis pmpailis commented Oct 20, 2025

Removing the requirement for > 2 fork branches. So a query like

            FROM test
            | WHERE id > 2
            | FORK
               ( WHERE content:"fox" )
            """

will now be allowed, and only fork1 will be added to the result set.

Closes #135825

@elasticsearchmachine
Copy link
Collaborator

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

@pmpailis
Copy link
Contributor Author

@ioanatia went through the documentation but could not find any specific references to the >= 2 branches limitation that needed to be updated.

@pmpailis pmpailis marked this pull request as ready for review October 20, 2025 13:41
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Oct 20, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

expectError("FROM foo* | FORK (LIMIT 10)", "line 1:13: Fork requires at least 2 branches");
expectError("FROM foo* | FORK (SORT a)", "line 1:13: Fork requires at least 2 branches");
expectError("FROM foo* | FORK (WHERE x>1 | LIMIT 5)", "line 1:13: Fork requires at least 2 branches");
expectError("FROM foo* | WHERE x>1 | FORK (WHERE a:\"baz\")", "Fork requires at least 2 branches");
Copy link
Contributor

Choose a reason for hiding this comment

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

can we get a test for FORK with no branches? I think the grammar does not support it, but I don't think I added a test for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in a8ce7b9. I've also added a test in FuseIT to consume the result of a single-branched FORK. Let me know if you see any issues :)

@ioanatia
Copy link
Contributor

also thought a bit more about the discussion we had around doing an optimization, like in the LogicalPlanBuilder when a single FORK branch is being used, to not even use the FORK logical plan, but have a "linear" plan.
You had a good intuition that we do have certain limitations for FORK, for example we only allow a single FORK command per query. If we do this optimization, we break this limitation which could be surprising for users.
So just removing the validation for now, with no optimizations, makes sense to me 👍

@pmpailis
Copy link
Contributor Author

Thanks for reviewing this (again) @ioanatia !

@pmpailis pmpailis merged commit c3cc3d1 into elastic:main Oct 21, 2025
34 checks passed
chrisparrinello pushed a commit to chrisparrinello/elasticsearch that referenced this pull request Oct 24, 2025
fzowl pushed a commit to voyage-ai/elasticsearch that referenced this pull request Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Relevance/ES|QL Search functionality in ES|QL Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES|QL: Allow a single FORK branch

3 participants