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

Speed up the function_score query when scores are not needed. #12693

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Aug 6, 2015

This change improves the function_score query to not compute scores at all
when they are not needed, and to not compute scores on the underlying query
when the combine function is to replace the score with the scores of the
functions.

This change improves the `function_score` query to not compute scores at all
when they are not needed, and to not compute scores on the underlying query
when the combine function is to replace the score with the scores of the
functions.
@jpountz jpountz added >enhancement review :Search/Search Search-related issues that do not fall into other categories v2.0.0 labels Aug 6, 2015
@@ -127,6 +127,13 @@ public Explanation explainScore(int docId, Explanation subQueryScore) throws IOE
}

@Override
public boolean needsScores() {
// Scripts might use _score so we return true here
// TODO: Make scripts able to tell us whether they use scores
Copy link
Contributor

Choose a reason for hiding this comment

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

By the way: lucene expressions "know this"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we speak I'm working on another change to expose this. :-)

@rmuir
Copy link
Contributor

rmuir commented Aug 6, 2015

+1, wonderful

@nik9000
Copy link
Member

nik9000 commented Aug 6, 2015

LGTM. I like how you push the hard part of the TODO closer to the problem and get wins on the "easier" parts.

jpountz added a commit that referenced this pull request Aug 6, 2015
…score_query_when_replacing_score

Speed up the `function_score` query when scores are not needed.
@jpountz jpountz merged commit 8590fa4 into elastic:master Aug 6, 2015
@jpountz jpountz deleted the enhancement/speed_up_function_score_query_when_replacing_score branch August 6, 2015 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants