我试图编写一个在文档类型上聚合的查询。问题是,文档类型可以从文档id中获得--它是id的第4-5个字符,比如BPR:fawL5CcPE72Wf3m93hU2。
下面是我放在一起的查询:
{
"query": {
"match_all": { }
},
"aggregations": {
"by_document_type": {
"script": {
"script": "doc['_id'].value.substring(0, 3)",
"order": {
"_count": "desc"
}
}
}
}
}但上面写着Parse Failure [Could not find aggregator type [script] in [by_document_type]]];。
我做错什么了?
发布于 2015-09-03 08:54:49
您只需使用 aggregation并在其中输入脚本:
{
"query": {
"match_all": {}
},
"aggregations": {
"by_document_type": {
"terms": {
"script": "doc['_id'].value.substring(0, 3)",
"order": {
"_count": "desc"
}
}
}
}
}https://stackoverflow.com/questions/32371060
复制相似问题