All Products
Search
Document Center

Tablestore:How do I increase the value of the limit parameter to 1000 when I call the Search operation of the search index feature to query data?

Last Updated:Nov 06, 2024

When you call the Search operation of the search index feature to query data, the maximum value of the limit parameter is automatically increased to 1000 if the search index contains all columns that you want to return. In this case, you can configure the limit parameter to increase the number of rows that are returned in the response. If the search index does not contain all columns that you want to return, you must query data from the data table. In this case, the maximum value of the limit parameter is 100. This topic describes how to increase the value of the limit parameter to 1000 when you call the Search operation of the search index feature to query data.

Methods

When you call the Search operation of the search index feature to query data, you can use the ColumnsToGet parameter to specify the columns that you want to return. If the columns that you specify are contained in the search index, the value of the limit parameter is automatically increased to 1000. To increase the number of rows in the response, you can configure the ColumnsToGet parameter to specify the columns that are contained in the search index as the columns that you want to return or set the ReturnAllColumnsFromIndex parameter to true to ensure that the columns that you want to return are contained in the search index, and then increase the value of the limit parameter.

If the existing search indexes do not contain all columns that you want to return and you want the value of the limit parameter to automatically increase to 1000, you can add all columns that you want to return to a search index when you create the search index or dynamically modify the schema of an existing search index to add all columns that you want to return to the search index. For more information, see Create a search index and Dynamically modify the schema of a search index.

Examples

The following sample code provides an example on how to increase the value of the limit parameter to 1000 by configuring the ColumnsToGet parameter in SearchRequest in Tablestore SDK for Java. The method to increase the value of the limit parameter is similar in Tablestore SDKs for other programming languages.

SearchQuery searchQuery = new SearchQuery();
searchQuery.setQuery(new MatchAllQuery());
searchQuery.setLimit(1000);

SearchRequest searchRequest = new SearchRequest(tableName, indexName, searchQuery);

// Method 1: Set the columns parameter in the ColumnsToGet parameter to the columns that are contained in the search index to return specific attribute columns in the search index. 
ColumnsToGet columnsToGet = new ColumnsToGet();
columnsToGet.setReturnAll(false);
// Set the columns parameter to the names of columns in the search index. 
columnsToGet.setColumns(Arrays.asList("field_1", "field_2", "field_3"));  
searchRequest.setColumnsToGet(columnsToGet);

// Method 2: Set the returnAllColumnsFromIndex parameter in ColumnsToGet to true to return all attribute columns in the search index. 
// Tablestore SDK for Java V5.6.1 or later supports the returnAllColumnsFromIndex parameter. 
ColumnsToGet columnsToGet = new ColumnsToGet();
columnsToGet.setReturnAllFromIndex(true);
searchRequest.setColumnsToGet(columnsToGet);

SearchResponse response = client.search(searchRequest);