Functions
You can use plugin functions in a `filter` clause to filter data, and use functions that return numeric values in a `sort` clause to sort data.
Document fields used as function parameters must be created as indexes or properties.
multi_attr: Returns the value at a specified position in an array field
1. Usage:
multi_attr(field, pos, default_value=0|"")
2. Parameters:
field: The name of the field to query. The field must be an ARRAY type and configured as an attribute field. pos: An integer constant or an integer field. If an integer field is specified, it must be configured as an attribute field. The index is 0-based. default_value(sorting score): Optional. A string constant. This value is returned if a value does not exist at the specified position.
3. Return value:
If the `value` at the specified `pos` exists, the `function` returns the `value` at that `index` in the `array`.
If the `value` at the specified `pos` does not exist and the `default_value` parameter is not set, the `function` returns 0.
If the `value` at the specified `pos` does not exist and the `default_value` parameter is set, the `function` returns the `default_value`.
4. Scenarios:
Scenario 1: A product has multiple prices, such as market price, discount price, and sales price, stored in the `prices` field. Query for mobile phones with a sales price less than 1000.
query=deault:'phone'&&filter=multi_attr(price,2)<1000Scenario 2: A product has multiple prices, such as market price, discount price, and sales price, stored in the `prices` field. Sort the `query` results in ascending order by the discount price. If the discount price does not exist or the `prices` field is `empty`, use a `default` `value` of 600.
query=default:'mobile phone'&&sort=+multi_attr(price,1,"600")5. Notes:
Fields used as `function` parameters must be created as properties.
Enclose the `default_value` in double quotation marks.