All Products
Document Center

OpenSearch:kvpair clause

Last Updated:Feb 03, 2023


You can use the kvpair clause to assign values to fields that are referenced in the mutable part of a sort expression. This way, you can pass field values to specific feature functions by using a query clause.


The kvpairs clause is in the following format: key1:value1,key2:value2

  • key1 indicates a field and values1 indicates the value of the field. Separate the field and value in a key-value pair with a colon (:).

  • You can specify multiple key-value pairs as needed. Separate multiple key-value pairs with commas (,).

Usage notes

  • The kvpairs clause is optional.


Use the following query clause to search for documents that contain Zheda. The retrieved documents are aggregated based on the company_id field. A total of one extraction is performed. In the extraction, one document is extracted. The remaining documents after the extraction are discarded and only the extracted document is returned.


Use the following query clause to search for documents that contain Zheda based on the match condition of 13=10:100=1. In this case, the tag_match function is used. The match condition takes effect on a tag field of the INT_ARRAY type. The tag field contains multiple attribute pairs. The values for the attributes that match a key are added together to generate a sum. If multiple keys are matched, the largest sum is retained.

query=default:'Zheda'&&kvpairs=query_key:13=10:100=1  // The fine sort expression is tag_match(query_key, tags, sum, max, true, true).