Clause description
The kvpairs clause is used to define parameters for the variable parts of a sort expression. This clause passes information from a query statement to specific feature functions.
Clause syntax
kvpairs=key1:value1,key2:value2
-
key1 is a key in the kvpairs clause, and value1 is its corresponding value. Use a colon (:) to separate the key and the value.
-
You can define multiple key-value pairs as needed. Use a comma (,) to separate each pair.
Example:
This example searches for documents that contain "Zhejiang University". This query aggregates results by the company_id field. It extracts and then discards one result per round. The final result count excludes these discarded documents.
query=default:'Zhejiang University'&&distinct=dist_key:company_id,dist_count:1,dist_times:1,reserved:false&&kvpairs=duniqfield:company_id
This example searches for documents that contain "Zhejiang University". This query uses the tag_match relevance feature function to match values in the tags field. The tags field is an int_array type that contains property pairs. The query uses the following values for the match: key1=13, value1=10, key2=100, and value2=1. If a match is found, the function calculates a sum. If multiple keys are hit, the function returns the maximum value.
query=default:'Zhejiang University'&&kvpairs=query_key:13=10:100=1 // The fine sort expression is tag_match(query_key, tags, sum, max, true, true)
Notes
-
The kvpairs clause is optional.