Elasticsearch Server - Third Edition by Rafal Kuc & Marek Rogozinski

Elasticsearch Server - Third Edition by Rafal Kuc & Marek Rogozinski

Author:Rafal Kuc & Marek Rogozinski [Kuc, Rafal]
Language: eng
Format: epub, mobi
Publisher: Packt Publishing
Published: 2016-02-28T23:00:00+00:00


Field value factor function

The field_value_factor function allows us to influence the score of the document by using a value of the field in that document. For example, to multiply the score of the document by the value of the year field, we run the following query:

curl -XGET 'localhost:9200/library/_search?pretty' -d '{ "query" : { "function_score" : { "query" : { "term" : { "available" : true } }, "functions" : [ { "field_value_factor" : { "field" : "year", "missing" : 1 } } ] } } }'

In addition to choosing the field whose value should be used, we can also control the behavior of the field value factor function by using the following properties:

factor: The multiplication factor that will be used along with the field value. It defaults to 1.

modifier: The modifier that will be applied to the field value. It defaults to none. It can take the value of log, log1p, log2p, ln, ln1p, ln2p, square, sqrt, and reciprocal.

missing: The value that should be used when a document doesn't have any value in the field specified in the field property.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.