Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException on top_hits subaggregation of nested #8668

Closed
pzol opened this issue Nov 26, 2014 · 6 comments
Closed

NullPointerException on top_hits subaggregation of nested #8668

pzol opened this issue Nov 26, 2014 · 6 comments
Assignees

Comments

@pzol
Copy link

pzol commented Nov 26, 2014

From the log file

[2014-11-26 15:49:42,502][INFO ][cluster.metadata         ] [Ch'od] [bug] creating index, cause [api], shards [5]/[1], mappings [ari]
[2014-11-26 15:51:12,270][DEBUG][action.search.type       ] [Ch'od] [bug][1], node[r8Z50Ip0TTGcDcu8XDi4ow], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@24f7ac80] lastShard [true]
java.lang.NullPointerException
[2014-11-26 15:51:12,369][DEBUG][action.search.type       ] [Ch'od] [bug][4], node[r8Z50Ip0TTGcDcu8XDi4ow], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@24f7ac80]
java.lang.NullPointerException
[2014-11-26 15:51:12,270][DEBUG][action.search.type       ] [Ch'od] [bug][2], node[r8Z50Ip0TTGcDcu8XDi4ow], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@24f7ac80] lastShard [true]
java.lang.NullPointerException
[2014-11-26 15:51:12,270][DEBUG][action.search.type       ] [Ch'od] [bug][0], node[r8Z50Ip0TTGcDcu8XDi4ow], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@24f7ac80] lastShard [true]
java.lang.NullPointerException

The query

POST /bug/ari/_search
{
   "aggs": {
      "mhcs": {
         "aggs": {
            "prices": {
               "nested": {
                  "path": "prices"
               },
               "aggs": {
                  "min_price": {
                     "min": {
                        "field": "total"
                     }
                  },
                  "aggs": {
                      "top_hits": {
                          "size": 1
                      }
                  }
               }
            },
            "aggs": {
               "top_hits": {
                  "_source": [
                     "mhc",
                     "checkin"
                  ],
                  "size": 1
               }
            }
         },
         "terms": {
            "field": "mhc"
         }
      }
   },
   "size": 0
}

The mapping

{
    "mappings": {
        "ari": {
            "_all": {
                "enabled": false
            },
            "dynamic": "false",
            "properties": {
                "adt": {
                    "type": "integer"
                },
                "chd": {
                    "type": "integer"
                },
                "checkin": {
                    "format": "date",
                    "type": "date"
                },
                "currency": {
                    "index": "not_analyzed",
                    "type": "string"
                },
                "ext_code": {
                    "index": "not_analyzed",
                    "type": "string"
                },
                "meal": {
                    "index": "not_analyzed",
                    "type": "string"
                },
                "mhc": {
                    "index": "not_analyzed",
                    "type": "string"
                },
                "prices": {
                    "type": "nested",
                    "properties": {
                        "source": {
                            "index": "not_analyzed",
                            "type": "string"
                        },
                        "stay": {
                            "type": "integer"
                        },
                        "total": {
                            "type": "double"
                        }
                    }
                },
                "room": {
                    "index": "not_analyzed",
                    "type": "string"
                },
                "tlc": {
                    "index": "not_analyzed",
                    "type": "string"
                }
            }
        }
    }
}

The data

{"index":{"_id":"AAH000022014112520DZF", "_type":"ari"}}
{ "tlc": "AAH", "mhc": "AAH00002", "room": "DZ", "ext_code": "AAH305", "currency": "EUR", "meal": "F", "checkin": "20141125", "adt": 2, "chd": 0, "prices":[{"stay": 1, "total": 42.38},{"stay": 2, "total": 84.77},{"stay": 3, "total": 127.16},{"stay": 4, "total": 169.54}]}
{"index":{"_id":"AAH000022014112620DZF", "_type":"ari"}}
{ "tlc": "AAH", "mhc": "AAH00002", "room": "DZ", "ext_code": "AAH305", "currency": "EUR", "meal": "F", "checkin": "20141126", "adt": 2, "chd": 0, "prices":[{"stay": 1, "total": 42.38},{"stay": 2, "total": 84.77},{"stay": 3, "total": 127.16}]}
{"index":{"_id":"AAH000022014112720DZF", "_type":"ari"}}
{ "tlc": "AAH", "mhc": "AAH00002", "room": "DZ", "ext_code": "AAH305", "currency": "EUR", "meal": "F", "checkin": "20141127", "adt": 2, "chd": 0, "prices":[{"stay": 1, "total": 42.38},{"stay": 2, "total": 84.77}]}
{"index":{"_id":"AAH000022014112820DZF", "_type":"ari"}}
{ "tlc": "AAH", "mhc": "AAH00002", "room": "DZ", "ext_code": "AAH305", "currency": "EUR", "meal": "F", "checkin": "20141128", "adt": 2, "chd": 0, "prices":[{"stay": 1, "total": 42.38}]}
{"index":{"_id":"AAH000022014113020DZF", "_type":"ari"}}
{ "tlc": "AAH", "mhc": "AAH00002", "room": "DZ", "ext_code": "AAH305", "currency": "EUR", "meal": "F", "checkin": "20141130", "adt": 2, "chd": 0, "prices":[{"stay": 1, "total": 42.38}]}
@martijnvg martijnvg self-assigned this Nov 26, 2014
@martijnvg
Copy link
Member

Hey @pzol on what ES version did you run into this?

Also I see that you put a top_hits aggregation under a nested aggregation. This isn't supported yet, but will be from ES version 1.5: #7164

@pzol
Copy link
Author

pzol commented Nov 26, 2014

Ah thanks, that's 1.4.0

The error is misleading if it's not supported. I'll be waiting for 1.5 then :)

@martijnvg
Copy link
Member

I just verified that the top_hits agg under the nested agg is really causing the NPE.

I agree that this error is misleading. I'll make sure that we fail at parse time instead of with a cryptic NPE for the next 1.4 release.

@pzol
Copy link
Author

pzol commented Nov 26, 2014

Shall I close this issue or you want to keep it?

@martijnvg
Copy link
Member

Lets keep it around until #8673 gets merged in.

martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Nov 27, 2014
martijnvg added a commit that referenced this issue Nov 27, 2014
@martijnvg
Copy link
Member

Implemented via: #8673

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants