Skip to content

Conversation

@Samiul-TheSoccerFan
Copy link
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan commented Jul 28, 2025

This PR is the first part of multi_match implementation with semantic_text field.

This PR includes:

  • Update getFieldName to handle fieldName along with its per field boost.
  • supply field boost value into each intercepter.
  • Update intercepter framework to handle the updated function name.
PUT my_documents
{
  "mappings": {
    "properties": {
      "title": {
        "type": "text"
      },
      "content": {
        "type": "text"
      }
    }
  }
}

PUT my_documents/_doc/1
{ 
  "title": "Introduction to Machine Learning",
  "content": "This guide covers supervised and unsupervised learning." 
}

PUT my_documents/_doc/2
{ 
  "title": "Solar Panels for Beginners",
  "content": "Learn how solar energy works and its benefits."
}

POST my_documents/_search --works as expected
{
  "query": {
    "multi_match": {
      "query": "learn solar energy",
      "fields": ["title", "content^2"],
      "boost": 3.0
    }
  }
}


PUT my_semantic_documents
{
  "mappings": {
    "properties": {
      "title": {
        "type": "semantic_text"
      }
    }
  }
}

PUT my_semantic_documents/_doc/1
{ 
  "title": "Introduction to Machine Learning"
}

PUT my_semantic_documents/_doc/2
{ 
  "title": "Solar Panels for Beginners"
}

POST my_semantic_documents/_search -- fails as expected
{
  "query": {
    "multi_match": {
      "query": "learn solar energy",
      "fields": [
        "title^2"
      ],
      "boost": 3.0,
      "_name": "semantic_query"
    }
  }
}

PUT my_another_semantic_documents
{
  "mappings": {
    "properties": {
      "title": {
        "type": "text"
      },
      "content": {
        "type": "semantic_text"
      }
    }
  }
}

PUT my_another_semantic_documents/_doc/1
{ 
  "title": "Introduction to Machine Learning",
  "content": "This guide covers supervised and unsupervised learning." 
}

PUT my_another_semantic_documents/_doc/2
{ 
  "title": "Solar Panels for Beginners",
  "content": "Learn how solar energy works and its benefits."
}

POST my_another_semantic_documents/_search -- fails as expected
{
  "query": {
    "multi_match": {
      "query": "learn solar energy",
      "fields": [
        "title",
        "content"
      ]
    }
  }
}

@Samiul-TheSoccerFan Samiul-TheSoccerFan added >enhancement :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search - Relevance The Search organization Search Relevance team v9.2.0 labels Jul 28, 2025
@elasticsearchmachine elasticsearchmachine added the Team:SearchOrg Meta label for the Search Org (Enterprise Search) label Jul 28, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Hi @Samiul-TheSoccerFan, I've created a changelog YAML for you.

Copy link
Contributor

@Mikep86 Mikep86 left a comment

Choose a reason for hiding this comment

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

We don't need a changelog for this PR. Let's label it as >refactor to remove that.

public SemanticQueryRewriteInterceptor() {}

@Override
public QueryBuilder interceptAndRewrite(QueryRewriteContext context, QueryBuilder queryBuilder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes to this method are not effectively preparing for the changes that will actually necessary to support multi_match here. I suggest taking some time to think about how you will change this method to properly support multi_match, making an implementation plan, and then determining which parts of that plan can and should be done as part of this initial refactor PR.

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine update branch

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine update branch

1 similar comment
@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine update branch

@Samiul-TheSoccerFan Samiul-TheSoccerFan force-pushed the refactor-intercept-rewriter-for-multi-match branch from 96f7dde to 7cace0b Compare August 28, 2025 06:53
@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine update branch

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticsearchmachine update branch

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine update branch

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine update branch

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

Labels

>refactoring :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) v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants