All Products
Search
Document Center

fieldterm_proximity

Last Updated: Sep 09, 2021

Feature functions

You can use feature functions in sort expressions. Most feature functions can be used only in fine sort expressions. You can combine various syntax and clauses to perform complex sorts.

The fields that you reference in parameters of feature functions must be configured as index or attribute fields based on the description of each function.

fieldterm_proximity: returns the proximity of terms in a field

    1.Syntax:

    fieldterm_proximity(field_name)

    2.Parameters:

    field_name: the name of the field. The field must be of the TEXT or SHORT_TEXT type. The analyzer can be the general analyzer for Chinese, a custom analyzer, or the single character analyzer for Chinese.

    3.Return value:

    The return value is of the FLOAT type. Valid values: [0,1].

    4.Scenario:

    In the fine sorting stage, the proximity of the title and body fields in the query is calculated. The proximity of the title field is weighted higher in sorting. You can use the following fine sorting expression:

    fieldterm_proximity(title)*10 + fieldterm_proximity(body)

5.Usage notes:

  • The field that you reference in the parameter of this function must be configured as an index field.

  • Measurement metrics: the distance between hit words in the field and the mutual order of hit words in the field.

  • This feature is used only for fine sorting and is included in text_relevance(). In regular scenarios, you do not need to use the fieldterm_proximity() and text_relevance() functions together.