Getting the Double values instead of Integer using JestClient to retrieve document from elasticsearch.
Index mapping -
"makeId": {
"type": "integer"
},
"makeName": {
"type": "keyword"
},
"yearId": {
"type": "integer"
}
I am using JestClient (In java) to get the fields value, I'm expecting makeId and yearId values as integer, but values are returned as Double,
Jest maven Depandency -
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>2.0.0</version>
</dependency>
Java code -
String[] reqFields = { "makeName","makeId","yearId" };
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolquery = QueryBuilders.boolQuery();
boolquery.must(QueryBuilders.matchQuery("yearId", yearId));
searchSourceBuilder.query(boolquery).fetchSource(reqFields, null).size(9000);
Search.Builder searchBuilder = new Search.Builder(searchSourceBuilder.toString()).addIndex(indexName).addType(indexType);
SearchResult result = jestClient.execute(searchBuilder.build());
List<Hit<Map, Void>> hits = result.getHits(Map.class);
after this line SearchResult gets Source object as integer values (as I am expecting)
SearchResult result = jestClient.execute(searchBuilder.build());
Response:-
{"took":29,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1466,"max_score":1.0,"hits":[{"_index":"vehicle","_type":"vehicle_dev","_id":"836","_score":1.0,"_source":{"makeId":2,"makeName":"BUICK","yearId":2012}},{"_index":"vehicle","_type":"vehicle_dev","_id":"1915","_score":1.0,"_source":{"makeId":5,"makeName":"CHEVROLET","yearId":2012}},{"_index":"vehicle","_type":"vehicle_dev","_id":"2511","_score":1.0,"_source":{"makeId":5,"makeName":"CHEVROLET","yearId":2012}},{"_index":"vehicle","_type":"vehicle_dev","_id":"2324","_score":1.0,"_source":{"makeId":5,"makeName":"CHEVROLET","yearId":2012}}
(Expected)
but when next line executed -
List<Hit<Map, Void>> hits = result.getHits(Map.class);
Response:-
{makeId=2.0, makeName=BUICK, yearId=2012.0, es_metadata_id=836}
Unexpected
Values got changed into Double i..e 2.0 from 2.