Not able to get any results on using bucket aggregations

I have some PR data in my ES. This is how the documents are modelled

 {
          "Author" : "dheerajrav",
          "Date" : "2012-10-05T10:16:49Z",
          "Number" : 2554441,
          "IsMerged" : false,
          "MergedBy" : "",
          "Body" : ""
        },
        {
          "Author" : "dheerajrav",
          "Date" : "2012-10-05T09:11:35Z",
          "Number" : 2553883,
          "IsMerged" : false,
          "MergedBy" : "",
          "Body" : ""
        },
        {
          "Author" : "crodjer",
          "Date" : "2012-10-04T15:40:22Z",
          "Number" : 2544540,
          "IsMerged" : false,
          "MergedBy" : "",
          "Body" : ""
        },
        {
          "Author" : "crodjer",
          "Date" : "2012-10-04T07:52:20Z",
          "Number" : 2539410,
          "IsMerged" : false,
          "MergedBy" : "",
          "Body" : ""
        }
      .
      .
      .
      ]
    }

I am trying the following terms agg on my index but I get no results

curl -X GET "localhost:9200/newidx/_search?pretty" -H 'Content-Type: application/json' -d'               
{
"aggs" : {
    "contributors" : {
        "terms" : {
            "field" : "Author",
            "size" : 100
        }
    }
  }
}
'

The desired result would have been separate buckets for each PR author. This is the response

 "aggregations" : {
 "contributors" : {
  "doc_count_error_upper_bound" : 0,
  "sum_other_doc_count" : 0,
  "buckets" : [ ]
   }
  }

Am I modeling my data wrong?

What is the mapping?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

This is the mapping for my index

{
  "newidx" : {
   "mappings" : {
     "properties" : {
         "Stats" : {
          "properties" : {
           "Author" : {
             "type" : "text",
              "fields" : {
               "keyword" : {
                  "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "Body" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "Date" : {
          "type" : "date"
        },
        "IsMerged" : {
          "type" : "boolean"
        },
        "MergedBy" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "Number" : {
          "type" : "long"
           }
         }
       }
     }
    }
 }
}

I generate a json file in my code and index it to elasticsearch using elasticsearch_loader, here is the command

elasticsearch_loader --es-host 'localhost' --index org-skills --type incident json --lines processed.json

Try to run the agg on Stats.Author.keyword.

Why do you index those inner objects all together instead of a document per object?

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