Skip to content

Semantic Query Rewrite Interception Drops Boosts #128696

@Mikep86

Description

@Mikep86

Elasticsearch Version

9.1

Installed Plugins

No response

Java Version

bundled

OS Version

N/A

Problem Description

match, knn, and sparse_vector queries that target semantic_text fields drop any boosts applied to those queries when they are rewritten.

This happens because the query interception logic makes incomplete copies of the queries during rewrite. Other information is lost in this copy operation as well, such as any name assigned to the query.

Steps to Reproduce

  1. Create an index with a semantic_text field
PUT my-index
{
  "mappings": {
    "properties": {
      "title": {
        "type": "text"
      },
      "author": {
        "type": "text"
      },
      "summary": {
        "type": "text",
        "copy_to": "semantic_summary"
      },
      "semantic_summary": {
        "type": "semantic_text"
      },
      "moral_lesson": {
        "type": "text",
        "copy_to": "semantic_moral"
      },
      "semantic_moral": {
        "type": "semantic_text"
      }
    }
  }
}
  1. Add docs to the index
POST my-index/_doc/1
{
  "title": "Cinderella",
  "author": "Charles Perrault",
  "summary": "Cinderella is a young girl mistreated by her stepmother and stepsisters until she meets a fairy godmother.",
  "moral_lesson": "Goodness and kindness will always be rewarded."
}

POST my-index/_doc/2
{
  "title": "Little Red Riding Hood",
  "author": "Brothers Grimm",
  "summary": "A young girl encounters a cunning wolf on her way to visit her grandmother.",
  "moral_lesson": "Beware of strangers."
}
  1. Query a semantic_text field using a match query with a boost
GET my-index/_search
{
  "query": {
    "match": {
      "semantic_moral": {
        "query": "danger",
        "boost": 2.0
      }
    }
  }
}

Logs (if relevant)

No response

Metadata

Metadata

Labels

:SearchOrg/RelevanceLabel for the Search (solution/org) Relevance team>bugTeam:Search - RelevanceThe Search organization Search Relevance teamTeam:SearchOrgMeta label for the Search Org (Enterprise Search)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions