field_term_match_count

更新时间:
复制 MD 格式

Feature functions

You can use feature functions in sort expressions. Most of these functions support only fine sort expressions. You can combine various syntax and statements to create powerful sorting features.

The document fields that you use as parameters for feature functions must be configured as an index or a property, as specified in the documentation for the function.

field_term_match_count: Get the number of terms in a field that match the search query

1. Usage details:

field_term_match_count(field_name,index_name)

2. Parameters:

  • field_name: The name of the field to count. The field type can be TEXT, basic Chinese tokenization, custom tokenization, single-word tokenization, English tokenization, or fuzzy tokenization.

  • index_name: The name of the index for field_name. This parameter is optional.

3. Return value:

int

4. Scenarios:

Scenario 1:

You can process documents differently based on the number of matching terms in a field.

if (field_term_match_count(title) > 5, 0.8, 0.6)

5. Notes:

  • The field that you specify as a parameter must have an index.

  • This function can be used in fine sort expressions.

  • The function counts the number of matching terms in the field. Duplicate terms are counted multiple times.