Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/120354.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 120354
summary: Move scoring in ES|QL out of snapshot
area: ES|QL
type: enhancement
issues: []
2 changes: 2 additions & 0 deletions docs/reference/esql/metadata-fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ supported ones are:
* <<mapping-ignored-field,`_ignored`>>: the ignored source document fields. The field is of the type
<<keyword,keyword>>.

* `_score`: when enabled, the final score assigned to each row matching an ES|QL query. Scoring will be updated when using <<esql-search-functions,full text search functions>>.

To enable the access to these fields, the <<esql-from,`FROM`>> source command needs
to be provided with a dedicated directive:

Expand Down
136 changes: 67 additions & 69 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.tokens

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ public enum Cap {
/**
* Support the "METADATA _score" directive to enable _score column.
*/
METADATA_SCORE(Build.current().isSnapshot()),
METADATA_SCORE,

/**
* Term function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.dissect.DissectParser;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.xpack.esql.VerificationException;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.common.Failure;
import org.elasticsearch.xpack.esql.core.expression.Alias;
import org.elasticsearch.xpack.esql.core.expression.Attribute;
Expand Down Expand Up @@ -262,8 +261,7 @@ public LogicalPlan visitFromCommand(EsqlBaseParser.FromCommandContext ctx) {
for (var c : ctx.metadata().UNQUOTED_SOURCE()) {
String id = c.getText();
Source src = source(c);
if (MetadataAttribute.isSupported(id) == false // TODO: drop check below once METADATA_SCORE is no longer snapshot-only
|| (EsqlCapabilities.Cap.METADATA_SCORE.isEnabled() == false && MetadataAttribute.SCORE.equals(id))) {
if (MetadataAttribute.isSupported(id) == false) {
throw new ParsingException(src, "unsupported metadata field [" + id + "]");
}
Attribute a = metadataMap.put(id, MetadataAttribute.create(src, id));
Expand Down