The config clause is used to specify configurations such as the position of the first document to be returned, the number of documents to be returned, the data format of return results, and the number of documents to be sorted by a fine sort expression.
Syntax description
Parameter | Type | Required | Valid value | Default value | Description |
start | int | No | [0, 5000] | 0 | The ordinal number of the first document to be returned in search results. |
hit | int | No | [0, 500] | 10 | The maximum number of documents that can be returned. |
format | string | No | json | The data format of return results. The JSON and fullJSON formats are supported. Compared with the JSON format, the fullJSON format supports extra fields, such as variableValue and sortExprValues. | |
rerank_size | int | No | [0, 2000] | 200 | The number of documents to be sorted by a fine sort expression based on one column. |
total_rank_size | int | No | - | - | The number of documents to be sorted by a rough sort expression. |
total_rerank_size | int | No | [0,10000] | - | The number of documents to be sorted by a fine sort expression. |
default_operator | string | No | 'AND' or 'OR' | AND | The default query operator used in this query. Note: This parameter is supported only for exclusive instances. |
Usage notes
The config clause is optional.
Separate the key-value pairs of parameters with commas (,).
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. If you need to obtain more than 5,000 data entries on multiple pages, you can perform a scroll search to export the documents at a time and implement paging. For more information, see Scroll searches.
The default_operator parameter is supported only for exclusive instances.
The total_rank_size parameter is specified in different formats in OpenSearch SDKs for different languages. In OpenSearch SDK for Java, specify this parameter in the following format:
config.addToCustomConfig("total_rank_size:200000");
. In OpenSearch SDK for PHP, specify this parameter in the following format:$params->setCustomConfig('total_rank_size', 200000);
.You can view the sort details of documents by adding a parameter to your code.
Method: Add the format:fulljson parameter to a config clause.
In the returned results, the sortExprValues parameter indicates the sort information of a document.
"sortExprValues": [ "10000.0340123586" ]
The value of the sortExprValues parameter is an array, which is the value of the sort field in a sort clause. Example:
sort=-price;-RANK
In this case, the value of the sortExprValues parameter is in the format of [price, document score].
If you do not configure a sort clause, the value of the sortExprValues parameter is the document score by default.
Examples
Configure paging. In this example, 20 documents are returned on each page.
# 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
Set the maximum number of documents to be retrieved to 100.
config=start:0, hit:20, total_rank_size:100