Skip to content
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

Add new Script Score Query #31461

Closed
8 of 9 tasks
mayya-sharipova opened this issue Jun 20, 2018 · 1 comment · Fixed by #40186
Closed
8 of 9 tasks

Add new Script Score Query #31461

mayya-sharipova opened this issue Jun 20, 2018 · 1 comment · Fixed by #40186
Assignees
Labels
>enhancement :Search Relevance/Ranking Scoring, rescoring, rank evaluation. Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@mayya-sharipova
Copy link
Contributor

mayya-sharipova commented Jun 20, 2018

Replace Function Score Query with a new Script Score Query that will compute custom score through painless scripting.

GET /_search
{
    "query": {
        "script_score" : {
            "query": {
                "match": { "message": "elasticsearch" }
            },
            "script" : {
              "source": "Math.log(2 + doc['likes'].value)"
            },
            "min_score" : 2
        }
    }
}

Tasks:

  • Introduce a new Script Score Query
  • Develop documentation and tests for it (partially done)
  • Handle missing and multiple values in Script
    - addressed through Missing fields values unexpectedly return 0 in painless #29286 (PR submitted)
  • Introduce a new Script context in the painless
  • Add random score function to the Script context (done in Add randomScore function in script_score query #40186)
    - java's Random method should be sufficient
    - make random function that uses Lucene doc ids
    - ScriptScoreBuilder#doToQuery - investigate if we can dd salt - IndexName/ShardID to context manually
  • Add math functions to the Script context
    - rational and sigmoid functions were added
    - other functions can be implemented through Java's Math module
    - later we will be able to drop "Math" prefix in Script context
  • Add decay functions to the Script context
  • Add cosine similarity functions on dense and sparse vector fields
  • Add normalization functions to the Script context
    - will not be implemented as the implementation can be very slow, and values can be normalized through log, rational, sigmoid and other functions

relates to #27588, #30303

@mayya-sharipova mayya-sharipova self-assigned this Jun 20, 2018
@mayya-sharipova mayya-sharipova added >enhancement :Search Relevance/Ranking Scoring, rescoring, rank evaluation. labels Jun 20, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this issue Mar 19, 2019
To make script_score query to have the same features
as function_score query, we need to add randomScore
function.

This function should be able to produce different
random scores on different index shards.
It also needs to be able to produce random scores
based on the internal Lucene Document Ids.
To achieve this three variables have been added to
the score script context:
- _doc for the internal Lucene doc id
- _shard for the shard id
- _indexName for the index name

Closes elastic#31461
@javanna javanna added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Relevance/Ranking Scoring, rescoring, rank evaluation. Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants