OpenSearch sort policies use expressions and functions to control how search results are ranked through rough sort and fine sort stages.
Overview
Sort expressions support basic operations (arithmetic, relational, logical, bitwise, and conditional), mathematical functions, and fine sort functions. OpenSearch provides relevance-based sorting for typical applications such as forums and news applications. You can select an expression template based on your data characteristics and customize it to create your own expression. For more information, see Sort policies.
Rough sort selects the top N high-quality documents from all retrieved results. These documents are then scored and ranked during fine sort, ensuring users receive the most relevant results. Because rough sort affects search performance and fine sort determines the final ranking, you can apply key fine sort factors during rough sort for an efficient initial pass. For more information, see Rough sort functions.
Fine sort expressions score and rank the rough-sorted results to return the optimal results. You can define custom sort expressions for your applications and specify them in search queries. For more information, see Fine sort functions.
Cava is a programming language developed by the OpenSearch engine team based on the Low-Level Virtual Machine (LLVM) project. It uses Java-like syntax and delivers C++-level performance. Cava is object-oriented and supports just-in-time (JIT) compilation and various security checks for more robust programs. You can use Cava and the Cava libraries provided by OpenSearch to build dedicated sort plug-ins. For more information, see Develop sort plugins using Cava.