Empty aggregation buckets


I am just starting to experiment and learn elasticsearch and need a little help. I am using elasticsearch 2.0 with kibana 4.0. I have some json documents that I loaded into elasticsearch and was experimenting with kibana. By using the python client, I modified the mapping before loading the data and I used the following mapping for string fields:

{"type": "string", "fields": {"raw": {"type": "string", "index": "not_analyzed"}}}

After indexing my data with this mapping, kibana has stopped showing simple aggregations for terms.
This is the request being fired and even on sense, the buckets are empty:

POST mixpanel/people_profiles/_search
  "size": 0,
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "query": "*"
  "aggs": {
    "3": {
      "terms": {
        "field": "$properties.$city.raw",
        "size": 20,
        "order": {
          "_count": "desc"


  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  "hits": {
    "total": 81065,
    "max_score": 0,
    "hits": []
  "aggregations": {
    "3": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []

Can anyone please help me understand why this is happening?

So I dug a little deeper and it would seem there is something wrong with the settings that I am specifying while creating the index in Python using the client. I was simply specifying the mappings and no other settings. Why is that affecting the aggregations?

I was able to find the exact problem. Still not sure as to why it is causing a problem though. It is happening because of nested type:

body = {
    "mappings": {
        TYPE: {
            'properties': {
                '$properties': {
                    "type": "nested",
                    'properties': mapping_properties

If I take off the "type": "nested", it solves the problem.

I referred this post to design the mappings: https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-mapping.html . But it looks like that was api v1.4. Excerpt from https://www.elastic.co/guide/en/elasticsearch/reference/2.0/nested.html

Because nested documents are indexed as separate documents, they can only be accessed within the scope of the nested query, the nested/reverse_nested, or nested inner hits.

For instance, if a string field within a nested document has index_options set to offsets to allow use of the postings highlighter, these offsets will not be available during the main highlighting phase. Instead, highlighting needs to be performed via nested inner hits.

I guess that answers my question.