query_term_match_count

更新时间:
复制 MD 格式

Feature functions

Feature functions can be used in sort expressions. Most are supported only in fine sort expressions. You can combine various syntax and statements to create powerful sorting features.

If a document field is used as a parameter in a feature function, create an index or property for the field as specified in the function's documentation.

query_term_match_count: Gets the number of query terms that hit a document

1. Usage details:

query_term_match_count(field_name,index_name)

2. Parameters:

  • field_name: Optional. The name of the field for which to count hits. This field can be of type TEXT and use basic Chinese, custom, single-word, English, or fuzzy tokenization. If you do not specify this parameter, the function returns the total number of term hits across all fields by default.

  • index_name: Optional. The name of the index that corresponds to `field_name`.

3. Return value:

int

4. Scenarios:

Scenario 1: Perform different actions based on the number of query term hits in the `title` field of a document. if (query_term_match_count(title) > 10, 0.5, 1)

Scenario 2: Perform different actions based on the total number of query term hits. if (query_term_match_count() > 10, 0.5, 1)

5. Notes:

  • If you specify a field as a function parameter, you must create a corresponding index for that field.

  • This function can be used in fine sort expressions.

  • The function counts the number of term hits from the search query. Repeated terms are counted multiple times.