I have a problem retrieving all the docs, that do not have corresponding other logs by field value. I would appreciate any help given. The easiest to explain is with an example:
I have the following 5 docs:
DOC1:
{
message: **Step1**,
id: 100
}
DOC2:
{
message: **Step2**,
id: 100
}
DOC3:
{
message: **Step1**,
id: 200
}
DOC4:
{
message: **Step2**,
id: 300
}
DOC5:
{
message: **StepX**,
id: 400
}
So what I would like as a response from a query, would be all the docs, where Step1 does not have the corresponding Step2, where id value is the same. In the example below, this is (RESPONSE I WANT): DOC3:
{
message: Step1,
id: 200
}
What I tried so far is not the result I would like. This returns count of docs by id and ascending order, but since we have many other Steps, this is not ok, and results with count 1 will not be always correct.
GET index/_search
{
"size": 0,
"aggs" : {
"langs" : {
"terms" : {
"field" : "id",
"size" : 10,
"order": {
"_count": "asc"
}
}
}
}
}
MORE DETAILS In response, I need docs, that does not have 2 docs related with one id field (each result should have only 1 doc with related id and message=Step1).