Use a Painless script to create a weight for use in a similarity script. The weight makes up the part of the similarity calculation that is independent of the document being scored, and so can be built up front and cached.
Queries that contain multiple terms calculate a separate weight for each term.
- The boost value if provided by the query. If this is not provided the
- The number of documents that have a value for the current field.
- The sum of all terms that exist for the current field. If this is not
available the value is
- The sum of occurrences in the index for all the terms that exist in the
current field. If this is not available the value is
- The number of documents that contain the current term in the index.
- The total occurrences of the current term in the index.
- A scoring factor used across all documents.
The standard Painless API is available.