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.

To increase the number of returned rows in a query, call the Search operation in search indexes. If only data in search indexes is queried, the value of the limit parameter automatically increases to 1000. If data in tables is queried, the value of the limit parameter is 100.

Procedure

To increase the value of the limit parameter to 1000, perform the following operations:
  1. When you create a search index, you must set the value of the store parameter to true for the specified column.
    • If you create a search index in the Tablestore (OTS) console, the default value of the store parameter is true. You do not need to specify this parameter.
    • If you use SDKs to create a search index, you must set the value of the store parameter in FieldSchema to true for the specified column.
  2. When you call the Search operation to query data, you must specify the ColumnsToGet parameter in SearchRequest.
    The ColumnsToGet parameter returns only columns for which indexes are created in search indexes. If the data type of the returned columns is not ARRAY, DATE, GEOPOINT, or NESTED, the value of the limit parameter automatically increases to 1000.
    Note If the ColumnsToGet parameter returns columns whose data type is ARRAY, DATE, GEOPOINT, or NESTED, the table is queried when you call the Search operation. In this case, the value of the limit parameter remains at 100.

Examples

In this example, OTS SDK for Java is used to describe how to specify the ColumnsToGet parameter. The configuration method for this SDK is similar to that for OTS SDKs for other languages. You need to modify only the ColumnsToGet parameter in SearchRequest.

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

SearchRequest searchRequest = new SearchRequest(tableName, indexName, searchQuery);
ColumnsToGet columnsToGet = new ColumnsToGet();
columnsToGet.setReturnAll(false);
columnsToGet.setColumns(Arrays.asList("field_1", "field_2", "field_3"));  // Set the names of the returned columns. The data type of the returned columns cannot be ARRAY, DATE, GEOPOINT, or NESTED. Otherwise, the table is queried. 
searchRequest.setColumnsToGet(columnsToGet);
SearchResponse response = client.search(searchRequest);

// OTS SDK for Java V5.6.1 and later allow you to specify the returnAllColumnsFromIndex parameter in ColumnsToGet to query all attribute columns in search indexes. 

ColumnsToGet columnsToGet = new ColumnsToGet();
columnsToGet.setReturnAllFromIndex(true);
searchRequest.setColumnsToGet(columnsToGet);
SearchResponse response = client.search(searchRequest);