The following is the Index mapping created using NEST .AutoMap from object
{
"staff" : {
"mappings" : {
"staff" : {
"properties" : {
"dob" : {
"type" : "date"
},
"id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"salary" : {
"type" : "float"
},
"staffname" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
On using simple query I am getting this result
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 1.0,
"hits" : [
{
"_index" : "staff",
"_type" : "staff",
"_id" : "15530",
"_score" : 1.0,
"_source" : {
"id" : "15530",
"staffname" : "muhammad khayyam",
"dob" : "1995-08-01T00:00:00",
"salary" : 20000.0
}
},
{
"_index" : "staff",
"_type" : "staff",
"_id" : "15525",
"_score" : 1.0,
"_source" : {
"id" : "15525",
"staffname" : "muhammad khayyam",
"dob" : "1995-08-01T00:00:00",
"salary" : 50000.0
}
},
{
"_index" : "staff",
"_type" : "staff",
"_id" : "15526",
"_score" : 1.0,
"_source" : {
"id" : "15526",
"staffname" : "muhammad khayyam",
"dob" : "1995-08-01T00:00:00",
"salary" : 80000.0
}
},
{
"_index" : "staff",
"_type" : "staff",
"_id" : "15527",
"_score" : 1.0,
"_source" : {
"id" : "15527",
"staffname" : "muhammad khayyam",
"dob" : "1995-08-01T00:00:00",
"salary" : 20000.0
}
},
{
"_index" : "staff",
"_type" : "staff",
"_id" : "15529",
"_score" : 1.0,
"_source" : {
"id" : "15529",
"staffname" : "muhammad khayyam",
"dob" : "1995-08-01T00:00:00",
"salary" : 20000.0
}
}
]
}
}
my query is
POST /staff/_search
{
"size" : 0,
"_source" : false,
"stored_fields" : "_none_",
"aggregations" : {
"groupby" : {
"composite" : {
"size" : 1000,
"sources" : [
{
"Date of birth" : {
"terms" : {
"field" : "dob",
"missing_bucket" : true,
"order" : "asc"
}
}
},
{
"Salary" : {
"terms" : {
"field" : "salary",
"missing_bucket" : true,
"order" : "asc"
}
}
}
]
}
}
}
}
Returning result
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"groupby" : {
"after_key" : {
"Date of birth" : 270777600000,
"Salary" : 80000.0
},
"buckets" : [
{
"key" : {
"Date of birth" : 270777600000,
"Salary" : 20000.0
},
"doc_count" : 3
},
{
"key" : {
"Date of birth" : 270777600000,
"Salary" : 50000.0
},
"doc_count" : 1
},
{
"key" : {
"Date of birth" : 270777600000,
"Salary" : 80000.0
},
"doc_count" : 1
}
]
}
}
}
As can be seen that result of Date of birth in Millisecond-to-epoch, need to get it converted to some specified format which is in Human readable form