Fine sort functions

更新时间:
复制 MD 格式

Fine sort expressions are used to score and sort the roughly sorted results and return the optimal results. You can customize sort expressions for applications and specify sort expressions in search queries to sort results. Sort expressions support basic operations, mathematical functions, and feature functions. The basic operations include arithmetic, relational, logical, bitwise, and conditional operations. OpenSearch provides expression templates for you to perform searches on typical applications, such as forum and news applications. You can select an appropriate expression template based on your data characteristics and modify the selected template to generate a custom expression. This topic describes supported fine sort functions.

Note

Note: To perform basic operations such as arithmetic, relational, logical, and conditional operations, you must use numbers or field values of the NUMERIC type in sort expressions. Most function-based operations cannot be performed on values of the STRING type.

Text relevance

  1. text_relevance: Calculates the text relevance between a search query and the field values in a document.

  2. text_relevance_llm: Calls a sorting model to sort search results.

  3. field_match_ratio: Returns the ratio of terms that match the search query to the total number of terms in a field.

  4. query_match_ratio: Returns the ratio of terms from the search query that are hit in a specific field to the total number of terms in the search query.

  5. fieldterm_proximity: Returns the proximity of terms in a field.

  6. field_length: Returns the number of terms in a field.

  7. query_term_count: Returns the number of terms in the search query after analysis.

  8. query_term_match_count: Returns the number of terms from the search query that are hit in a specific field of a document.

  9. field_term_match_count: Returns the number of terms in a field that match the search query.

  10. query_min_slide_window: Returns the ratio of the number of hit terms from the search query in a specific field to the minimum window that contains these terms in the field.

Geographical location relevance

  1. distance: Returns the spherical distance between two points. This function is typically used to calculate distances for location-based services (LBS).

  2. gauss_decay: Uses a Gaussian function to calculate the degree of attenuation based on the distance between a value and a specified origin point.

  3. linear_decay: Uses a linear function to calculate the degree of attenuation based on the distance between a value and a specified origin point.

  4. exp_decay: Uses an exponential function to calculate the degree of attenuation based on the distance between a value and a specified origin point.

Timeliness

  1. timeliness: Returns the timeliness score, which indicates how new a document is. The unit is seconds.

  2. timeliness_ms: Returns the timeliness score, which indicates how new a document is. The unit is milliseconds.

Algorithm relevance

  1. category_score: the category prediction function that returns the matching score between the specified category field in the parameters and the category obtained by the category prediction query.

  2. popularity: returns the popularity score of a commodity. The score indicates the popularity of the commodity.

Functionality

  1. tag_match: Matches queries with documents based on tags and scores the documents by calculating the weights of the matched tags.

  2. first_phase_score: Returns the score that is calculated by the rough sort expression.

  3. kvpairs_value: Returns the value of a specified field in the kvpairs clause of a query.

  4. normalize: A normalization function that scales values from different scoring ranges to the range of [0, 1].

  5. in/notin: Checks whether a field value is in or not in a specified list.