All Products
Search
Document Center

:text_relevance

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 the parameters of feature functions must be configured as index or attribute fields based on the description of each function.

text_relevance: calculates the text relevance between search queries and field values in documents

1.Syntax:

text_relevance(field_name)

2.Parameter:

field_name: the name of the field. An analyzer must be enabled for the field. The analyzer can be the common analyzer for Chinese, a custom analyzer, or the single character analyzer for Chinese. The field must be configured as an index field.

3.Return value:

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

4.Scenario:

Scenario 1: Calculate the text relevance for the title and body fields by using a fine sort expression. If the weight ratio of the title field to the body field is 3:1, the fine sort expression is text_relevance(title)*3+text_relevance(body).

5.Usage notes:

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

  • Measurement metrics: the proportion of hit words in the search query, the proportion of hit words in the field, the frequency of hit words in the field, the order of hit words in the field, and the order of hit words in the search query.

  • The text_relevance function can be used only in fine sort expressions.