I'm a beginner, when I use painless script to search ,very slowly ,but use date_histogram very quickly.
`POST /productinfo/_search
{
"aggs": {
"groupbyyear":{
"terms": {
"script": {
"lang": "painless",
"source":"doc['mdate'].value.year"
}
}
}
}
}`
the took is 2494
{ "took": 2494, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 23139644, "max_score": 1,
when I use datehist like this, the took only 438,can somebody tell me why,please!
`POST /productinfo/_search
{
"aggs": {
"groupbyyear":{
"date_histogram": {
"field": "mdate",
"interval": "year"
}
}
}
}`
the result:
{ "took": 438, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 23139644, "max_score": 1, "hits": [
like below also slowly........
POST /productinfo/_search { "aggs": { "groupbydep":{ "terms": { "script": { "lang": "painless", "source":"doc['pdep'].value.substring(0,4)" }
