## Feature functions

You can use feature functions in sort expressions. Most feature functions can be used only in fine sort expressions. You can combine various syntax and clauses to perform complex sorts.

**The fields that you reference in parameters of feature functions must be configured as index or attribute fields based on the description of each function.**

## normalize: normalizes scores in different value ranges to numeric values in the range of [0,1]

1.Scenario overview

The relevance of a document is calculated from different dimensions. The scores that are calculated from different dimensions may in different value ranges. For example, a web page can have millions of clicks while the text relevance score of the web page is a value from 0 to 1. You cannot compare such values in different value ranges. The normalize function can normalize the scores in different value ranges to scores in the same value range. This way, you can use the normalized scores for further calculation. The normalize function supports three normalization methods: linear normalization, log normalization, and arctangent normalization. The chosen normalization method varies based on the input parameters. If only the value parameter is set, the normalize function uses the arctangent function for normalization. If both the value and max parameters are set, the normalize function uses the logarithmic function for normalization. If all the value, max, and min parameters are set, the normalize function uses the linear function for normalization.

2.Syntax

normalize(value, max, min)

3.Parameters

**value**: the field in a document or the expression for which you want to normalize the field value or the return value. The field value or return value must be of the DOUBLE type.**max**: the maximum value of the value range after normalization. This parameter is optional. The maximum value must be of the DOUBLE type.**min**: the minimum value of the value range after normalization. This parameter is optional. The minimum value must be of the DOUBLE type.

4.Return value

The return value is of the DOUBLE type. Valid values: [0,1].

5.Scenarios

**Scenario 1**: You want to normalize the value of the price field but do not know the value range of the price field. In this case, you can use the normalize function in the following format: `normalize(price)`

.

**Scenario 2**: You want to normalize the value of the price field and know only the maximum value in the value range of the price field. In this case, you can use the normalize function in the following format: `normalize(price, 100)`

.

**Scenario 3**: You want to normalize the value of the price field and the maximum value and minimum value are 100 and 1. In this case, you can use the normalize function in the following format: `normalize(price, 100, 1)`

.

Scenario 4: You want to normalize the return value of the distance function to a value from 0 to 1. In this case, you can use the normalize function in the following format: `normalize(distance(longitude_in_doc, latitude_in_doc, longtitude_in_query, latitude_in_query))`

.

6.Usage notes:

The field referenced in the function must be set as an attribute field.

If the arctangent function is used for normalization and the field value or the return value of the specified expression is smaller than 0, the return value of the normalize function is 0.

If the logarithmic function is used for normalization, the value of the max parameter must be greater than 1.

If the linear function is used for normalization, the value of the max parameter must be greater than that of the min parameter.