# Elasticsearch missing one record via High level rest api

**URL:** <https://discuss.elastic.co/t/elasticsearch-missing-one-record-via-high-level-rest-api/103943>\
**Category:** Elasticsearch\
**Created:** [October 13, 2017, 7:04pm UTC](https://discuss.elastic.co/t/elasticsearch-missing-one-record-via-high-level-rest-api/103943 "2017-10-13T19:04:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashutosh\_Tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashutosh_tripathi/32/23043_2.png) [@Ashutosh\_Tripathi](https://discuss.elastic.co/u/Ashutosh_Tripathi)\
**Post date:** [October 13, 2017, 7:04pm UTC](https://discuss.elastic.co/t/elasticsearch-missing-one-record-via-high-level-rest-api/103943/1 "2017-10-13T19:04:04Z")

</div>

Hi,  
We are having trouble after moving to elasticsearch 5.6.x version from 5.0.x version. We always get one record less than the total number of records expected.  
We can verify the missing record since same elastic json query when run by curl gives us correct output.

Anyone has idea about it ? I am attaching the code snippet below.

```
    String parameter = "search keyword";

    final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(1L));
    SearchRequest searchRequest = new SearchRequest(elasticIndex);
    searchRequest.types("typename");
    searchRequest.scroll(scroll);
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

    BoolQueryBuilder query = QueryBuilders.boolQuery();
    searchSourceBuilder.query(query);
    // searchSourceBuilder.from(0);
    // searchSourceBuilder.size(1);
    searchRequest.source(searchSourceBuilder);

    MultiMatchQueryBuilder.Type type = MultiMatchQueryBuilder.Type.CROSS_FIELDS;
    Operator operator = Operator.AND;

    MultiMatchQueryBuilder multiMatchQuery = 
    QueryBuilders.multiMatchQuery(parameter,"first_name","last_name");
    multiMatchQuery.operator(operator);
    multiMatchQuery.type(type);
    query.filter(multiMatchQuery);
   
    SearchResponse response = null;
    try {
        response = elasticService.getElasticClientRest().search(searchRequest);
    } catch (IOException e) {
        e.printStackTrace();
    }
    String scrollId = response.getScrollId();
    SearchHit[] searchHits = response.getHits().getHits();
    System.out.println(searchSourceBuilder.toString());
    while (searchHits != null && searchHits.length > 0) {
        SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId);
        scrollRequest.scroll(scroll);
        try {
            response = elasticService.getElasticClientRest().searchScroll(scrollRequest);
        } catch (IOException e) {
            e.printStackTrace();
        }
        scrollId = response.getScrollId();
        searchHits = response.getHits().getHits();
        Arrays.stream(searchHits).forEach(o->{

            ObjectMapper mapper = new ObjectMapper();
            JsonNode actualObj = null;
            try{
                actualObj = mapper.readTree(o.getSourceAsString());
            }catch(Exception e){
                e.printStackTrace();
            }
            PropertiesDTO properties = Json.fromJson(actualObj, PropertiesDTO.class);
           //Results are processed
        });
     }
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 10, 2017, 7:04pm UTC](https://discuss.elastic.co/t/elasticsearch-missing-one-record-via-high-level-rest-api/103943/2 "2017-11-10T19:04:06Z")

</div>

Closed on November 10, 2017, 7:04pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
