I'm new to ElasticSearch and my scenario is something like, there is an index with some 100 documents. I'm using following snippet to retrieve those
ListenableActionFuture f = esClient.prepareSearch(index) .setTypes(type) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setQuery(multiMatchQuery) .execute();
I want to fetch all documents at one shot without using scroll. I know that index wont be having so many records. If I specify
ListenableActionFuture f = esClient.prepareSearch(index) .setTypes(type) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setQuery(multiMatchQuery) .setSize(100) .execute(); behaviour is inconsistent. Number of records getting fetched varies every time, sometimes 34 documents, sometimes 21 etc.
But if I dont specify size, its fetching 10 always. I'm using elasticsearch 5.6.3.
I have tried few solutions such as using without search type as below,but no luck
ListenableActionFuture f = esClient.prepareSearch(index) .setTypes(type) .setQuery(multiMatchQuery) .setSize(hitcount) .execute();
I need a query to fetch all records at one shot. When I try to print searchresponse,I found total hits is incorrect as below
hits": { "total": 25, "max_score": 0.18232156, "hits": [ { .... } }} It should be 100. Again if I execute, same code, I'm getting different total hits.
My index is having 5 shards
I'm wondering what makes me getting inconsistent total hits often.