У меня есть индекс эластичного поиска, где я храню все ответы на опрос в виде объекта json.
Пример:
{
"@timestamp": "2019-04-29T07:46:34.184Z",
"id": 54448437,
"questionResponses": [
{
"questionId": 1000000000,
"insights": [
{
"categoryId": 50071,
"feature": "experience",
"tonality": "positive",
"score": 1,
"id": 253042338,
"opinion": "great"
},
{
"categoryId": 50071,
"feature": "Overall Experience",
"tonality": "negative",
"score": -1,
"id": 253042357,
"opinion": "very misleading"
},
{
"categoryId": 50015,
"feature": "video",
"tonality": "negative",
"score": -1,
"id": 253042358,
"opinion": "misleading"
},
{
"categoryId": 50009,
"feature": "classes",
"tonality": "neutral",
"score": -1,
"id": 253042364,
"opinion": "didn't even get to attend."
}
],
"response": "While I had a great experience with both my girls, promising a NICU and having one available and open are two different things and very misleading. This whole video feels misleading to me. My birth plan was between me and my doctor both times and the hospital was just my location. They do offer classes but they fill super fast and we're very limited that I didn't even get to attend. I loved the attention and care that I received while there ...",
"id": 425994747
}
],
"source_name": "Survey 1"
}
Теперь у меня есть требование, когда мне нужно получить количество документов, основанное на сумме баллов оценок для идентификатора категории.
Мне нужно получить положительный документ и количество отрицательных документов.
Вывод должен выглядеть как
{"categoryId": 50071,
"positiveDocumentCount": 0,
"neutralDocumentCount": 1,
"negativeDocumentCount": 0}
{"categoryId": 50015,
"positiveDocumentCount": 0,
"neutralDocumentCount": 0,
"negativeDocumentCount": 1}