During elasticsearch query, it is found that hits []. Length is always 1 less than totalhits. Value
the code is as follows:
SearchRequest request = new SearchRequest("indexName"); SearchSourceBuilder builder = new SearchSourceBuilder(); BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); builder.query(QueryBuilder.matchPhraseQuery("fieldName","searchStr")); builder.from(1); builder.size(10); request.source(builder); SearchResponse response = restHighLevelClient.search(request,RequestOptions.DEFAULT); // Get the total number of queries System.out.println(response.getHits().getTotalHits().value); // Get the number of query paging System.out.println(response.getHits().getHits().length);
Output results:
The second line is always 1 less than the first line.
According to the idea of conventional paging, it should actually start from the first page and then keep up with the data of each page. Unexpectedly, from (1) directly skips the first data here.
Solution:
it’s OK to directly from (0).
Similar Posts:
- The differences between response. Getwriter(). Write() and response. Getwriter(). Print(), as well as pritwriter object and out object
- ES Error:”illegal_argument_exception” [How to Solve]
- How to Solve Request processing failed; nested exception is java.lang.NullPointerException
- [Solved] JpaRepository Error: Paging query needs to have a Pageable parameter! Offending method public abstract
- Resource interpreted as Stylesheet but transferred with MIME type text/html: css not work
- [ Elasticsearch-PHP] No alive nodes found in your cluster in
- Servlet jump mode sendredirect() and forward ()
- The difference between system.err.println and system.out.println
- Visit the back-end application through nginx and report an error err_ CONTENT_ LENGTH_ MISMATCH
- [Solved] Docker Run ElasticSearch Error: docker: invalid reference format: repository name must be lowercase.