Skip to content

Semantic Query Rewrite Interception Drops Boosts #128696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Mikep86 opened this issue May 30, 2025 · 2 comments
Open

Semantic Query Rewrite Interception Drops Boosts #128696

Mikep86 opened this issue May 30, 2025 · 2 comments
Labels
>bug :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search - Relevance The Search organization Search Relevance team Team:SearchOrg Meta label for the Search Org (Enterprise Search)

Comments

@Mikep86
Copy link
Contributor

Mikep86 commented May 30, 2025

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

@Mikep86 Mikep86 added >bug needs:triage Requires assignment of a team area label :SearchOrg/Relevance Label for the Search (solution/org) Relevance team labels May 30, 2025
@elasticsearchmachine elasticsearchmachine added the Team:SearchOrg Meta label for the Search Org (Enterprise Search) label May 30, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-eng (Team:SearchOrg)

@elasticsearchmachine elasticsearchmachine added Team:Search - Relevance The Search organization Search Relevance team and removed needs:triage Requires assignment of a team area label labels May 30, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search - Relevance The Search organization Search Relevance team Team:SearchOrg Meta label for the Search Org (Enterprise Search)
Projects
None yet
Development

No branches or pull requests

2 participants