This topic describes OpenSearch sort policies and the types of expressions and functions used by the policies.
Overview
Sort expressions support basic operations, mathematical functions, and fine sort functions. The basic operations include arithmetic operations, relational operations, logical operations, bitwise operations, and conditional operations. OpenSearch allows you to sort search results by relevance in typical applications, such as forum and news applications. You can select an appropriate expression template based on your data features and modify the selected template to generate a custom expression. For more information, see Configure sort policies.
Rough sort is the process of selecting the top N high-quality documents from all documents that are retrieved. Then, the top N high-quality documents are scored and sorted in the fine sort process. This way, users can obtain the documents that best match their requirements. Rough sort affects the search performance, whereas fine sort affects the ultimate sort results. Therefore, you can use key factors of fine sort to roughly sort documents in an efficient and simple manner. You can use sort expressions to roughly and finely sort documents. For more information, see Rough sort functions.
Fine sort expressions are used to score and sort the roughly sorted results to return the optimal results to you. You can customize sort expressions for applications and specify sort expressions in search queries to sort results. For more information, see Fine sort functions.
Cava is a programming language that is developed by the OpenSearch engine team based on the low-level virtual machine (LLVM) project. Cava uses the syntax similar to that of Java and can achieve the performance as efficient as C++. Cava is an object-oriented programming language. It supports just-in-time (JIT) compilation and various security checks to ensure more robust programs. You can use Cava and the Cava libraries that are provided by OpenSearch to design a dedicated sort plug-in in OpenSearch. For more information, see Cava for the development of sort plug-ins.