Skip to content

Conversation

@ioanatia
Copy link
Contributor

@ioanatia ioanatia commented Dec 9, 2025

There's a bug right now with FUSE, where WITH cannot be used before the other configurations (SCORE BY/GROUP BY/KEY BY):

FROM books METADATA _score, _id, _index
| FORK (WHERE title:"war and peace" | SORT _score DESC| LIMIT 100)
      (WHERE description:"war and peace" | SORT _score DESC| LIMIT 100)
| FUSE WITH {"rank_constant": 45} score by _score

returns:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "line 5:36: mismatched input 'score' expecting {<EOF>, '|', 'with', 'group', 'score', 'key'}"
      }
    ],
    "type": "parsing_exception",
    "reason": "line 5:36: mismatched input 'score' expecting {<EOF>, '|', 'with', 'group', 'score', 'key'}",
    "caused_by": {
      "type": "input_mismatch_exception",
      "reason": null
    }
  },
  "status": 400
}

This should not happen, looking at the parser, WITH/KEY BY/SCORE BY/GROUP BY don't need to be provided in any particular order:

fuseCommand
: FUSE (fuseType=identifier)? (fuseConfiguration)*
;
fuseConfiguration
: SCORE BY score=qualifiedName
| KEY BY key=fuseKeyByFields
| GROUP BY group=qualifiedName
| WITH options=mapExpression
;

The bug most likely has to do with mixing ANTLR push modes.
After spending some considerable time trying to fix it, I figured we can just follow the same pattern as the other commands that support options (using WITH), that just use EXPRESSION_MODE.
So I removed the custom Fuse.g4 lexer, and just used the Expression lexer like the other commands do 🙃 .
This not just simplifies how we define the syntax for FUSE, but it also fixes the bug we have.

@ioanatia ioanatia added >bug Team:Search - Relevance The Search organization Search Relevance team :Search Relevance/ES|QL Search functionality in ES|QL v9.3.0 labels Dec 9, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Search Relevance/ES|QL Search functionality in ES|QL Team:Search - Relevance The Search organization Search Relevance team v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants