Существует несколько уникальных идентификаторов, которые не содержат специальной информации. Начните отсюда и настройте при необходимости:
Настройка
PUT special_info
{
"mappings": {
"properties": {
"unique_id": {
"type": "keyword"
},
"information": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
Синхронизация c
POST _bulk
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"abc","information":"Some data"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"abc","information":"Special Information"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"abc","information":"Some data"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"def","information":"Some data"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"def","information":"Special Information"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"def","information":"Some data"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"ghi","information":"Some data"}
{"index":{"_index":"special_info","_type":"_doc"}}
{"unique_id":"ghi","information":"Some data"}
Запрос
GET special_info/_search
{
"query": {
"bool": {
"must_not": [
{
"term": {
"information.keyword": {
"value": "Special Information"
}
}
}
]
}
},
"_source": "unique_id",
"aggs": {
"by_unique_ids": {
"terms": {
"field": "unique_id"
}
}
}
}
выход
...
"aggregations" : {
"by_unique_ids" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "abc",
"doc_count" : 2
},
{
"key" : "def",
"doc_count" : 2
},
{
"key" : "ghi",
"doc_count" : 2
}
]
}
}