How to calculate grades from script_fields in elasticsearch?

Im creating a custom field using "script_fields". And I would like to use this field to create an assessment for documents. How can I achieve this in elastics search. It would be great if someone could send a sample request.

+1
source share
1 answer

This is not realistic, because when evaluating the document, the values ​​of the script field are not yet calculated. Search queries are usually performed in two stages: query and fetch . During the query, phase estimates are computed and the top documents are selected for retrieval. The list of top documents is then used during selection to retrieve documents. During this search process, script fields are computed.

In other words, to use a script to evaluate documents, you need to use this script in the request phase by placing it in function_score , e.g.

+3
source

Source: https://habr.com/ru/post/1625241/


All Articles