Aggregation on Nested fields with prefix query


(Jai Prakash Bhardwaj) #1

Please help me with the following issue:

{
  "size": 0, 
       "query": {
        "nested":{
"path": "locations",
"query":{
"multi_match" : {
"fields" : ["locations.CityName"],
"query" : "CH",
"type": "phrase_prefix"
}},
"inner_hits" : {
"_source": { "includes": ["locations.CityName"] }}
}}
         
       , 
    "aggs" : {
        "Location_Name" : {
            "nested" : {
                "path" : "locations"
            },
            "aggs" : {
                "City_Name" : { "terms" : { "field" : "locations.CityName.keyword" } }
            }
        }
    }
}

So, I should get all city with CH, but I get:

  "hits": {
    "total": 2,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "Location_Name": {
      "doc_count": 34,
      "City_Name": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 14,
        "buckets": [
          {
            "key": "CHILLICOTHE",
            "doc_count": 4
          },
          {
            "key": "SIOUX CITY",
            "doc_count": 4
          }

Please help me in the missed logic.

Best,
J


(Jai Prakash Bhardwaj) #2

Do we have anybody who can help me in this please?


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.