field_length

更新时间:
复制 MD 格式

Feature function items

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

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

field_length: Get the number of tokens in a field

1. Usage details:

field_length(field_name)

2. Parameters

field_name: The name of the field whose token count you want to obtain. This field must be of the TEXT or SHORT_TEXT type and must have an analyzer configured. The analyzer can be any of the following: Chinese basic tokenization, custom tokenization, single-word tokenization, English tokenization, or fuzzy analysis.

3. Return value

int

4. Scenarios

Scenario 1:

You can set different weights based on the number of tokens in a field.

if (field_length(title) > 200, 0.3, 0.7)

5. Notes

  • The field used as a parameter in the function must have an index of the required type.

  • This function can be used in fine sort expressions.