andrew.fox
andrew.fox

Reputation: 7933

Performance of "function_score"

I'm working on a solution for custom score boosting in Elasticsearch.

I wanted to ask if using function_score is a good idea. Because the index size is great but the result of the query should not be that big.

Does function_score work on a query result or rather as a part of query logic? If former, it might be fast, is it?

PS. Initially query boost operator seemed like a best option, but I can't get it to raise a score much above the normal range for one of the match. I've checked _explain API and it says that queryNorm normalizes my boost and I still get values below normal range (0.1 .. 4).

Upvotes: 1

Views: 1991

Answers (1)

Mysterion
Mysterion

Reputation: 9320

In principle - yes, it will slow down the performance of the search. Of course real penalty will depend on the complexity of your script. It will work during so called 'search' phase, so it means, that it will be applied for all matched docs.

You could try to make your logic faster, if your case is suitable for rescoring functionality, cause it's applied only to the top N (configurable in rescore API) results.

More information about rescoring - https://www.elastic.co/guide/en/elasticsearch/guide/current/_improving_performance.html#rescore-api

Upvotes: 2

Related Questions