I have 2 es indices. There are some records common in both the indices, I want to fetch them. My preliminary query is :-
GET index1,index2/_search
{
"size": 0,
"aggs": {
"duplicate record": {
"terms": {
"field": "Id"
},
"aggs": {
"get duplicate": {
"bucket_selector": {
"buckets_path": {
"doc_count": "_count"
},
"script": "params.doc_count == 2"
}
}
}
}
}
}
This query returns the following result:-
{
"took" : 687,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"duplicate record" : {
"doc_count_error_upper_bound" : 2,
"sum_other_doc_count" : 3000689,
"buckets" : [
{
"key" : "1989861726",
"doc_count" : 2
},
{
"key" : "1989861734",
"doc_count" : 2
},
{
"key" : "1989861860",
"doc_count" : 2
},
{
"key" : "1989862267",
"doc_count" : 2
},
{
"key" : "1989862280",
"doc_count" : 2
},
{
"key" : "1989862642",
"doc_count" : 2
},
{
"key" : "1989862730",
"doc_count" : 2
},
{
"key" : "2004088312",
"doc_count" : 2
},
{
"key" : "2004088315",
"doc_count" : 2
},
{
"key" : "2004088321",
"doc_count" : 2
}
]
}
}
}
I want full records associated with these id's. Can someone help me with that?