All Products
Search
Document Center

kvpair clause

Last Updated: Sep 09, 2021

Overview

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.

Function

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.

Examples

Use the following query clause to search for documents that contain "浙大". 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.

query=default:'浙大'&&distinct=dist_key:company_id,dist_count:1,dist_times:1,reserved:false&&kvpairs=duniqfield:company_id

Use the following query clause to search for documents that contain "浙大" 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:'浙大'&&kvpairs=query_key:13=10:100=1  // The fine sort expression is tag_match(query_key, tags, sum, max, true, true).