The config clause is used to specify configurations such as the offset, number of documents, and data format of return results, and the number of documents to be sorted by a fine sort expression.
Description
Parameter | Type | Required | Valid range | 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 in each result set. |
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. |
total_rank_size | INT | No | - | - | The number of documents to be sorted by a rough 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 return results, the sortExprValues parameter indicates the sort information of a document.
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
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
Set the maximum number of documents to be retrieved to 100.
config=start:0, hit:20, total_rank_size:100