elasticsearch中的数据包含一个名为facilityName
的字段。我有一个要求,我必须查看是否有facilityNameTypeCode
为“ UWI”且具有相同的facilityName
值的重复记录。以下是一个结构示例:
"facilityName": [
{
"facilityNameTypeId": {
"facilityNameTypeCode": "Name"
},
"facilityName": "Rishav jayswal"
},
{
"facilityNameTypeId": {
"facilityNameTypeCode": "Name"
},
"facilityName": "R.M"
}
]
这是我创建的查询:
GET _search
{
"query" : {
"term" : {"facilityName.facilityNameTypeId.facilityNameTypeCode" : "UWI"}
},
"aggs" : {
"duplicateNames": {
"terms": {
"field": "facilityName.facilityName",
"size": 0,
"min_doc_count": 2
}
}
}
}
但是我遇到了这个错误:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[terms] failed to parse field [size]",
"line": 10,
"col": 27
}
],
"type": "parsing_exception",
"reason": "[terms] failed to parse field [size]",
"line": 10,
"col": 27,
"caused_by": {
"type": "illegal_argument_exception",
"reason": "[size] must be greater than 0. Found [0] in [duplicateNames]"
}
},
"status": 400
}
有人可以建议如何做吗?
答案 0 :(得分:0)
错误很明显
[大小]必须大于0。在[duplicateNames]中找到[0]
因此,只需将大小设置为大于0的值,将其设置为0并没有多大意义
"terms": {
"field": "facilityName.facilityName",
"size": 10,
"min_doc_count": 2
}