0

i have index in es and this is the corresponding mapping :

'''

 GET /vid_detect2/_mapping
            
        {

            "properties": {
                "date":{"type":"date"},
                "time":{ "type": "text",
                         "fielddata": true},
                "frame_id": {"type":"integer"},
                "camera_id":{"type":"integer"},
                "path":{"type":"text"},
                "objects" : {"type": "nested", 
                             "properties": {
                                            "class":    { "type": "text" ,"fielddata":true },
                                            "confidence": { "type": "float"  },
                                             "coordinates":{ "type": "nested" ,
                                                             "properties": { "x" :{"type":"float"},
                                                                             "y" :{"type":"float"},
                                                                             "w" :{"type":"float"},
                                                                             "h" :{"type":"float"}
                                                             }  }
        
                                            }
                
            }
        
    }
}'''

I want to run following query first :

 "query": {
 "bool": {
  "must": [
   {
     "nested": {
    "path": "objects", 
    "query": {
      "bool": {
        "must": [ 
          { "match": { "objects.class": "person" }}
        
        ]
}}}}
]
 }}

and then aggregate the returned results with respect to camera_id and further aggregate those aggregated results with date histogram. Please help.

1 Answer 1

1

Good start! You can now simply add an aggregation section to achieve what you want:

{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "objects",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "objects.class": "person"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "camera": {
      "terms": {
        "field": "camera_id"
      },
      "aggs": {
        "histo": {
          "date_histogram": {
            "field": "date",
            "interval": "day"
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to create Tag cloud in Kibana on field "objects.class" but i am not able to find "object.class" field in visualize=>create=>tagcloud=>field. I tried to change the mapping as well by adding on "class": { "type": "text" ,"fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } Please help .
You should create a new question with your new need

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.