Feature functions
Feature functions can be used in sort expressions. Most are supported only in fine sort expressions. You can combine various syntaxes and statements to create powerful sorting features.
Document fields used as function parameters must be created as indexes or properties, as described in the documentation for the function..
query_match_ratio: Get the ratio of hit phrases to total phrases in a search query
1. Usage details:
query_match_ratio(field_name,index_name)
2. Parameters:
field_name: An optional parameter that specifies the name of the field for which to calculate the ratio. The field must be of the TEXT or SHORT_TEXT type. The field must also be configured with an analyzer, such as Chinese basic tokenization, custom tokenization, single-word tokenization, English tokenization, or fuzzy analysis.
index_name: An optional parameter that specifies the name of the index that corresponds to field_name.
3. Return value:
A float value in the range of [0, 1].
4. Scenarios:
Scenario 1: To check if all phrases in the search query hit the document: if (query_match_ratio() > 0.999, 1, 0)
Scenario 2: To check if all phrases in the search query hit the title field of the document: if (query_match_ratio(title) > 0.999, 1, 0)
5. Notes:
Fields used as function parameters must be created as indexes of the corresponding type.
This function can be used in fine sort expressions.