Feature functions
You can use feature functions in sort expressions. Most feature functions support only fine sort expressions. You can combine different syntaxes and statements to create powerful sorting features.
You must configure the document fields that are used as function parameters as an index or a property, as specified in the function's documentation.
fieldterm_proximity: Measures the proximity of keyword tokens within a field
1. Usage details:
fieldterm_proximity(field_name,index_name)
2. Parameters:
field_name: Optional. The name of the field used to calculate the proximity of keyword tokens. The field must be of the TEXT or SHORT_TEXT type and must be configured with one of the following analyzers: Chinese basic, custom, single-word tokenization, English, or fuzzy analysis.
index_name: Optional. The name of the index that corresponds to field_name.
3. Return value:
float. The value ranges from 0 to 1.
4. Scenarios
This function is useful for calculating query proximity in the title and body fields during the fine sort stage. If proximity in the title field has a greater impact on sorting, you can write the fine sort formula as follows:
fieldterm_proximity(title)*10 + fieldterm_proximity(body)5. Notes:
You must configure the fields that are used as function parameters as an index.
The function primarily measures two aspects: the distance between hit terms in the field and the relative order of the hit terms.
This feature is used only for fine sorting. It is also included in the text_relevance() function. Therefore, you do not need to use both fieldterm_proximity() and text_relevance() in typical scenarios.