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);
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.
it’s OK to directly from (0).
- 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
- [ Elasticsearch-PHP] No alive nodes found in your cluster in
- Resource interpreted as Stylesheet but transferred with MIME type text/html: css not work
- Servlet jump mode sendredirect() and forward ()
- The difference between system.err.println and system.out.println
- [Solved] Docker Run ElasticSearch Error: docker: invalid reference format: repository name must be lowercase.
- Visit the back-end application through nginx and report an error err_ CONTENT_ LENGTH_ MISMATCH
- Strange frame error caused by incorrect use of flash. Redirect (‘/ path’) in flash