Functionality functions
You can use functionality functions in filter clauses to define filter conditions. Functionality functions that return numeric values can be used in sort clauses for sorting.
The fields that you reference in the parameters of functionality functions must be configured as index or attribute fields based on the description of each function.
in or notin: judges whether field values are in a specific list
1. Syntax
in(field, "number1|number2")notin(field, "number1|number2")
2. Parameters
field: the name of the field to be judged. Only fields of the INT, LITERAL, FLOAT, or DOUBLE type are supported. Fields of the ARRAY or TEXT type and the analyzer for fuzzy searches are not supported. number N: the elements in a set. Separate multiple elements with vertical bars (|). Each element must be a string.
3. Return values
true/false
4. Scenarios
Scenario 1: Retrieve documents that contain "iphone" and the type field whose value is 1, 2, or 3. The type field must be of the INT type.
query=default:'iphone'&&filter=in(type, '1|2|3')
Scenario 2: Retrieve documents that contain "iphone" and the type field whose value is not 1, 2, or 3. The type field must be of the INT32 type.
query=default:'iphone'&&filter=notin(type, '1|2|3')
5. Usage notes
The field that you reference in the parameters of the functions must be configured as an attribute field.
If you use the in or notin function in filter clauses, you cannot use fields of the ARRAY type. Otherwise, the following syntax error with an error code of 6141 is returned: Filter clause syntax error.
Both the in(field, "number1|number2") function and the (field = number1) OR (field = number2) syntax can judge whether field values are in a specific list. However, the in function performs better. This rule also applies to the notin function.