All Products
Search
Document Center

OpenSearch:config clause

Last Updated:Feb 28, 2024

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

NUMBERIC

0

The offset value from which the system starts to return documents in the result set.

hit

NUMBERIC

10

The maximum number of documents in each result set.

format

'json' and 'xml'

'xml'

The format of the query results.

rank_trace

'FATAL', 'ERROR', 'INFO', 'DEBUG', 'WARN', 'TRACE1', 'TRACE2', and 'TRACE3'

None

The output information about the scoring process of a document in the front end.

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' 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. Otherwise, the operator that is specified in the query_config configuration item is used.

timeout

NUMBERIC

0

The timeout period of the query. Unit: milliseconds. The value cannot be a negative number.

seek_timeout

NUMBERIC

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 and yes

no

If this parameter is set to yes, only the first-phase query is run and the summary is not queried.

dedup

no and 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

NUMBERIC

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. This value cannot exceed 5000.

actual_hits_limit

NUMBERIC

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 less than the value of the actual_hits_limit parameter, the actual value is returned. If the actual number of returned records is more 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 number of records is returned. If the numeric_limits<uint32_t>::max() condition is met, the actual number of records is returned.

sourceid

string

None

Multiple replicas are available for indexes online. If you do not set the sourceid parameter, 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, 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

BOOLEAN

false

Specifies whether to perform the second scoring process for the query.

rank_size

NUMBERIC

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 is 0, the value in the configuration file is used.

rerank_size

NUMBERIC

0

If the number of finely sorted documents in the first scoring process is 0, the value in the configuration file is used.

total_rank_size

NUMBERIC

0

The sum of roughly sorted documents in all partitions or the number of documents that are truncated based on a dynamic index. If the value is 0, the value in the configuration file is used.

total_rerank_size

NUMBERIC

0

The sum of finely sorted rows of each partition. If the value is 0, the value in the configuration file is used.

fetch_summary_type

docid, pk, and 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 use the last two methods.

research_threshold

NUMBERIC

0

If the number of records is less than the value of this parameter, the query is performed again.

Examples

  1. Use the config clause to configure paging. In this example, each page of the query 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

  1. 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 a parameter and the value of the 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.