All Products
Document Center

Cava for the development of sort plug-ins

Last Updated: Sep 22, 2021

Cava is an efficient programming language that is developed by the OpenSearch engine team based on the low-level virtual machine (LLVM) project. Cava uses similar syntax to Java and can achieve equivalent performance 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. Compared with the expressions that are supported by OpenSearch, a Cava-based sort plug-in has the following benefits:

  • More customization features: Cava supports more syntax features than expressions, such as for loops, function definition, and class definition. You can use these features to customize a sort plug-in based on your business requirements.

  • Easier to maintain: Cava code is easier to understand than expressions. Therefore, a sort plug-in that is developed by using Cava is easier to maintain.

  • Easier to learn: Cava uses similar syntax to Java, which reduces learning costs. You can use Cava to develop a sort plug-in with ease if you are familiar with Java.



Cava-based plug-ins can be used in only exclusive applications.

Cava-based plug-ins take effect only for fine sorts.

For more information about the syntax of Cava, see the topics about Cava-based sort plug-ins in Developer Guide.


1.Create a policy: On the Policy Management page, click Create. On the Create Policy page, select Fine Sort from the Scope drop-down list and select Cava Script from the Type drop-down list.


2.Create or upload script files: You can create and edit script files. Alternatively, you can upload on-premises script files. A script file must be of the JSON format and cannot exceed 10 KB in size. Each script supports a maximum of five script files.


3.Compile and publish a script: After you edit the script files, click Compile to compile all the script files. You can view the compilation status below the Compile button. After the compilation is complete, click Publish to publish the script files. Published scripted files cannot be modified.


4.Test the sorting effect: On the Search Test page of the created policy, set the second_rank_name parameter to the name of the policy and the second_rank_type parameter to cava_script.



  • Cava-based plug-ins can be used only on exclusive applications.

  • A Cava script file cannot exceed 10 KB in size. Each script supports a maximum of five script files. Each application supports a maximum of 50 Cava scripts.

  • Published Cava script cannot be edited. If you want to edit a published Cava script, you can replicate the policy of the Cava script on the Policy Management page.