Overview
A config clause is a required part of a query statement that is used for real-time configuration of a query. For example, you can use a config clause to specify the offset, the number of returned records, the format of the query results, and the timeout period of the query.
Syntax
config=key1:value1,key2:value2...
You can replace key1 and key2 with the parameters described in the following table, and value1 and value 2 with the valid values of the parameters.
Parameter | Valid value | Default value | Description |
start | NUMBER | 0 | The offset value from which the system starts to return documents in the result set. |
hit | NUMBER | 10 | The maximum number of documents in each result set. |
format | json, xml | xml | The format of the query results. |
rank_trace | FATAL, ERROR, INFO, DEBUG, WARN, TRACE1, TRACE2, TRACE3 | None | The output information about the scoring process of a document in the frontend. |
default_index | string | "" | The default index that is used in this query. The default index is the same as the index that is specified in the query_config configuration item in the cluster configuration file. The index that you specify in a query is used as the default index. If you do not specify an index in the query, the index that is specified in the query_config configuration item is used. |
default_operator | AND, OR | "" | The default operator that is used in the query. The default operator is the same as the operator that is specified in the query_config configuration item in the cluster configuration file. If you specify an operator in the query, the operator specified in the query is preferentially used as the default operator. If you do not specify an operator in the query, the operator that is specified in the query_config configuration item is used. |
timeout | NUMBER | 0 | The timeout period of the query. Unit: milliseconds. The value cannot be a negative number. |
seek_timeout | NUMBER | 0 | The timeout period of the query seeking phase. Unit: milliseconds. Default value: 0. By default, the specified timeout period multiplied by 0.7 is used as the seeking timeout period. |
no_summary | no, yes | no | If this parameter is set to yes, only the first-phase query is run and the summary is not queried. |
dedup | no, yes | yes | If this parameter is set to yes, duplicates are automatically removed from the result based on the primary key. If this parameter is set to no, duplicates are not removed from the result. |
searcher_return_hits | NUMBER | 0 | The number of records that are returned by the searcher. If the value is 0, the records are returned based on the values of the start and hit parameters. The value of the searcher_return_hits parameter cannot exceed 5000. |
actual_hits_limit | NUMBER | 0 | Specifies whether the value of the totalhits parameter is an actual value or an estimated value. If the actual number of returned records is smaller than the value of the actual_hits_limit parameter, the actual value is returned. If the actual number of returned records is greater than the value of the actual_hits_limit parameter, the estimated value is returned. If the actual number of returned records is 0, the estimated value is returned. If the numeric_limits<uint32_t>::max() condition is met, the actual value is returned. |
sourceid | string | None | Multiple replicas are available for indexes online. If you do not configure the sourceid parameter for replicas, a replica is randomly selected for each query. When an index is incrementally updated, the updated data may not be synchronized to all replicas. As a result, the most recent query result may not be returned. After the value of the sourceid parameter is specified, a replica is selected for the query based on the hash value of the sourceid parameter. In this case, the users who use the same value of the sourceid parameter can query the latest data. The value of the sourceid parameter is of the string type. |
rerank_hint | BOOL | false | Specifies whether to perform the second scoring process for the query. |
rank_size | NUMBER | 0 | The number of documents that are roughly sorted or the number of documents that are dynamically truncated based on the rank_size parameter. If the value of this parameter is 0, the value in the configuration file is used. |
rerank_size | NUMBER | 0 | The number of documents that are finely sorted in the first scoring process. If the value of this parameter is 0, the value in the configuration file is used. |
total_rank_size | NUMBER | 0 | The sum of documents that are roughly sorted in all partitions or the number of documents that are truncated based on a dynamic index. If the value of this parameter is no, the value in the configuration file is used. |
total_rerank_size | NUMBER | 0 | The sum of documents that are finely sorted in the first scoring process of each partition. If the value of this parameter is 0, the value in the configuration file is used. |
fetch_summary_type | docid, pk, rawpk | docid | The method that is used to obtain the summary. By default, the summary is obtained based on docid. You can also specify to obtain the summary based on the hash value or the original value of the primary key. We recommend that you obtain the summary based on the hash value or the original value of the primary key. |
research_threshold | NUMBER | 0 | If the number of records is less than the value of this parameter, the query is performed again. |
Example
Use the config clause to configure paging. In this example, each page of return results displays 20 documents.
# The config clause for the first page.
config=start:0, hit:20, format:xml
# The config clause for the second page.
config=start:20, hit:20, format:xml
Set the number of documents to be sorted by a fine sort expression to 1000.
config=start:0, hit:20, rerank_size:1000
Usage notes
Separate the key and value of each parameter with a colon (:).
Make sure that the sum of the values of the start and hit parameters does not exceed 5,000. Otherwise, an error occurs and no results are returned.