How to aggregate in one field: value specified in the request in elasticsearch

Thus, my data in elasticsearch looks as follows: one identifier of one person is equal to one doctor and contains a list of objects of type

`{
  "dummy_name": "abc",
  "dummy_id": "44850642"
}`

which is shown below, the fact is that I request in the field dummy_id, and I get the result, since some are not. matching query results, and I want to aggregate in the field dummy_id, so I don’t get documents for a specific one dummy_id, but what happens, I also get buckets dummy_idthat are not mentioned in asking for his “I”, because the person contains a list of objects in which he is present dummy_id.

`{
  "person_id": 1234,
  "Properties": {
    "Property1": [
      {
        "dummy_name": "abc",
        "dummy_id": "44850642"
      },
      {

      },
      {

      }
    ]
  }
},
{
  "person_id": 1235,
  .........
}`

Iam using:

`{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "Properties.Property1.dummy_id": "453041 23234324 124324 "
          }
        }
      ]
    }
  },
  "aggregations": {
    "group_by_concept": {
      "terms": {
        "field": "Properties.Property1.dummy_id",
        "order": {
          "_count": "desc"
        },
        "size": 10
      }
    }
  }
}`
+4
source share
1 answer

, , , . ,

{
  "person_id": 1234,
  "Properties": {
    "Property1": [
      {
        "dummy_name": "abc",
        "dummy_id": "44850642"
      },
      {
        "dummy_name": "dfg",
        "dummy_id": "876468"
      },
      {

      }
    ]
  }
}

, ,

  • ID - 44850642,876468.This , Lucene

, dummy_id: 44850642

, , ,

, 44850642, 876468.

, elasticsearch , - https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html

0

Source: https://habr.com/ru/post/1692693/


All Articles