All Products
Search
Document Center

:multi_attr

Last Updated:Sep 09, 2021

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.

multi_attr: returns the value of the specified array field at the specified position

1.Syntax:

multi_attr(field, pos, default_value=0|"")

2.Parameters:

field: the name of the field whose value is to be obtained. The field must be of the ARRAY type. The field must be configured as an attribute field. pos: an integer constant or integer field. The field must be configured as an attribute field. The subscript starts from 0. default_value: a string constant. This parameter is optional. If the specified value of the pos parameter does not exist, the value specified by the default_value parameter is returned.

3.Return value:

The return value is of the same type as that of the field parameter.

4.Scenarios:

Scenario 1: Commodities have multiple prices, including market prices, discount prices, and sales prices. The prices are recorded in the prices field. You can use the following query clause to search for mobile phones whose sales price is less than 1,000:

query=default:'Mobile phone'&&filter=multi_attr(price,2)<1000

5.Usage notes:

  • The field that you reference in the parameter of the function must be configured as an attribute field.