Reputation: 155
final QueryBuilder contentTagQuery = QueryBuilders.boolQuery()
.filter( QueryBuilders.termQuery("tenantId" , "en"));
SearchHits<Content> searchHits =
elasticsearchOperations.search(
new NativeSearchQuery(contentTagQuery), Content.class,
IndexCoordinates.of("index"));
How can I add size in this query, as I only need the first result.
Upvotes: 0
Views: 265
Reputation: 19471
You can set this on the Query
instance:
NativeSearchQuery query = new NativeSearchQuery(contentTagQuery);
query.setMaxResults(1);
Upvotes: 1