{"action":"opened","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/15179","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15179/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15179/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15179/events","html_url":"https://github.com/elastic/elasticsearch/issues/15179","id":119925607,"number":15179,"title":"Geohash query not working after migrating to Elasticsearch 2.0/2.1","user":{"login":"jmatraszek","id":367639,"avatar_url":"https://avatars.githubusercontent.com/u/367639?v=3","gravatar_id":"","url":"https://api.github.com/users/jmatraszek","html_url":"https://github.com/jmatraszek","followers_url":"https://api.github.com/users/jmatraszek/followers","following_url":"https://api.github.com/users/jmatraszek/following{/other_user}","gists_url":"https://api.github.com/users/jmatraszek/gists{/gist_id}","starred_url":"https://api.github.com/users/jmatraszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmatraszek/subscriptions","organizations_url":"https://api.github.com/users/jmatraszek/orgs","repos_url":"https://api.github.com/users/jmatraszek/repos","events_url":"https://api.github.com/users/jmatraszek/events{/privacy}","received_events_url":"https://api.github.com/users/jmatraszek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-02T11:51:48Z","updated_at":"2015-12-02T11:51:48Z","closed_at":null,"body":"I am having trouble with my query after migrating to Elasticsearch 2.0/2.1. Previously used version 1.4. I am trying to do a GeoDistance query using geohash. That's the excerpt from ES response:\r\n\r\n    \"root_cause\": [\r\n      {\r\n        \"type\": \"query_parsing_exception\",\r\n        \"reason\": \"failed to find geo_point field [geohash]\",\r\n        \"index\": \"campaigns\",\r\n        \"line\": 1,\r\n        \"col\": 234\r\n      }\r\n    ]\r\n\r\nThe minimal index usable to reproduce this problem is as follows:\r\n\r\n    curl -s -X PUT \"http://localhost:9200/campaigns\" -d'{\r\n        \"settings\": {\r\n                \"analysis\": {\r\n                    \"filter\": {\r\n                        \"name_ngram\": {\r\n                            \"type\": \"nGram\",\r\n                            \"min_gram\": \"2\",\r\n                            \"max_gram\": \"50\"\r\n                        }\r\n                    },\r\n                    \"analyzer\": {\r\n                        \"search_analyzer\": {\r\n                            \"filter\": [\r\n                                \"standard\",\r\n                                \"asciifolding\",\r\n                                \"lowercase\",\r\n                                \"trim\"\r\n                            ],\r\n                            \"tokenizer\": \"standard\"\r\n                        },\r\n                        \"name_analyzer\": {\r\n                            \"filter\": [\r\n                                \"name_ngram\",\r\n                                \"standard\",\r\n                                \"asciifolding\",\r\n                                \"lowercase\",\r\n                                \"trim\"\r\n                            ],\r\n                            \"tokenizer\": \"standard\"\r\n                        }\r\n                    }                                                                                                                                                                                                                                                                \r\n                }                                                                                                                                                                                                                                                                    \r\n        },                                                                                                                                                                                                                                                                           \r\n        \"mappings\": {                                                                                                                                                                                                                                                                \r\n            \"campaign\": {                                                                                                                                                                                                                                                            \r\n                \"properties\": {                                                                                                                                                                                                                                                      \r\n                    \"locations\": {                                                                                                                                                                                                                                                   \r\n                        \"properties\": {                                                                                                                                                                                                                                              \r\n                            \"id\": {                                                                                                                                                                                                                                                  \r\n                                \"include_in_all\": false,                                                                                                                                                                                                                             \r\n                                \"type\": \"integer\"                                                                                                                                                                                                                                    \r\n                            },                                                                                                                                                                                                                                                       \r\n                            \"geohash\": {                                                                                                                                                                                                                                             \r\n                                \"type\": \"geo_point\"                                                                                                                                                                                                                                  \r\n                            }                                                                                                                                                                                                                                                        \r\n                        },                                                                                                                                                                                                                                                           \r\n                        \"type\": \"nested\"                                                                                                                                                                                                                                             \r\n                    },                                                                                                                                                                                                                                                               \r\n                    \"id\": {                                                                                                                                                                                                                                                          \r\n                        \"type\": \"integer\"                                                                                                                                                                                                                                            \r\n                    }                                                                                                                                                                                                                                                                \r\n                },                                                                                                                                                                                                                                                                   \r\n                \"_all\": {                                                                                                                                                                                                                                                            \r\n                    \"search_analyzer\": \"search_analyzer\",                                                                                                                                                                                                                            \r\n                    \"analyzer\": \"name_analyzer\"                                                                                                                                                                                                                                      \r\n                }                                                                                                                                                                                                                                                                    \r\n            }                                                                                                                                                                                                                                                                        \r\n        }                                                                                                                                                                                                                                                                            \r\n    }'\r\nI am using two analyzers here (as this is what I am using in my project, tried also with one analyzer and the result is the same).\r\n\r\nThe minimal data indexed in ES is as follows:\r\n\r\n    curl -s -X POST \"http://localhost:9200/campaigns/campaign\" -d'{\r\n        \"id\": 12,\r\n        \"locations\": [\r\n            {\r\n                \"id\": 13,\r\n                \"geohash\": {\r\n                    \"geohash\": \"s7ws01wyd7ws\"\r\n                }\r\n            }\r\n        ]\r\n    }'\r\n\r\nThe mapping in ES:\r\n\r\n    curl -s -X GET \"http://localhost:9200/campaigns/_mapping?pretty\"\r\n    {\r\n      \"campaigns\" : {\r\n        \"mappings\" : {\r\n          \"campaign\" : {\r\n            \"_all\" : {\r\n              \"analyzer\" : \"name_analyzer\",\r\n              \"search_analyzer\" : \"search_analyzer\"\r\n            },\r\n            \"properties\" : {\r\n              \"id\" : {\r\n                \"type\" : \"integer\"\r\n              },\r\n              \"locations\" : {\r\n                \"type\" : \"nested\",\r\n                \"properties\" : {\r\n                  \"geohash\" : {\r\n                    \"type\" : \"geo_point\"\r\n                  },\r\n                  \"id\" : {\r\n                    \"type\" : \"integer\",\r\n                    \"include_in_all\" : false\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n\r\nWorking query to search by \"locations.id\":\r\n\r\n    curl -s -X POST \"http://localhost:9200/campaigns/_search\" -d@'{\r\n      \"query\": {\r\n        \"filtered\": {\r\n          \"filter\": {\r\n            \"nested\": {\r\n              \"path\": \"locations\",\r\n              \"filter\": {\r\n                \"term\": {\r\n                  \"locations.id\": \"13\"\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }' | jq ''\r\n    {\r\n      \"took\": 5,\r\n      \"timed_out\": false,\r\n      \"_shards\": {\r\n        \"total\": 5,\r\n        \"successful\": 5,\r\n        \"failed\": 0\r\n      },\r\n      \"hits\": {\r\n        \"total\": 1,\r\n        \"max_score\": 1,\r\n        \"hits\": [\r\n          {\r\n            \"_index\": \"campaigns\",\r\n            \"_type\": \"campaign\",\r\n            \"_id\": \"AVFYQn4uic5h_a2BXp1k\",\r\n            \"_score\": 1,\r\n            \"_source\": {\r\n              \"id\": 12,\r\n              \"locations\": [\r\n                {\r\n                  \"id\": 13,\r\n                  \"geohash\": {\r\n                    \"geohash\": \"s7ws01wyd7ws\"\r\n                  }\r\n                }\r\n              ]\r\n            }\r\n          }\r\n        ]\r\n      }\r\n    }\r\n\r\nNot working query to search by \"geohash\" (only when the data is posted from file, but the same response is returned in my application):\r\n\r\n    cat query_geohash.json \r\n    {\r\n      \"query\": {\r\n        \"filtered\": {\r\n          \"filter\": {\r\n            \"nested\": {\r\n              \"path\": \"locations\",\r\n              \"filter\": {\r\n                \"geo_distance\": {\r\n                  \"distance\": \"100.0km\",\r\n                  \"geohash\": \"s7ws01wyd7ws\"\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n    curl -s -X POST \"http://localhost:9200/campaigns/_search\" -d@query_geohash.json | jq ''\r\n    {\r\n      \"error\": {\r\n        \"root_cause\": [\r\n          {\r\n            \"type\": \"query_parsing_exception\",\r\n            \"reason\": \"failed to find geo_point field [geohash]\",\r\n            \"index\": \"campaigns\",\r\n            \"line\": 1,\r\n            \"col\": 234\r\n          }\r\n        ],\r\n        \"type\": \"search_phase_execution_exception\",\r\n        \"reason\": \"all shards failed\",\r\n        \"phase\": \"query\",\r\n        \"grouped\": true,\r\n        \"failed_shards\": [\r\n          {\r\n            \"shard\": 0,\r\n            \"index\": \"campaigns\",\r\n            \"node\": \"cqrNlEmRSPGcGewKuUvlnA\",\r\n            \"reason\": {\r\n              \"type\": \"query_parsing_exception\",\r\n              \"reason\": \"failed to find geo_point field [geohash]\",\r\n              \"index\": \"campaigns\",\r\n              \"line\": 1,\r\n              \"col\": 234\r\n            }\r\n          }\r\n        ]\r\n      },\r\n      \"status\": 400\r\n    }\r\n\r\nStrangely, the same query works OK when the query is not read from file, but posted \"inline\":\r\n\r\n    curl -s -X POST \"http://localhost:9200/campaigns/_search\" -d@'{\r\n      \"query\": {\r\n        \"filtered\": {\r\n          \"filter\": {\r\n            \"nested\": {\r\n              \"path\": \"locations\",\r\n              \"filter\": {\r\n                \"geo_distance\": {\r\n                  \"distance\": \"100.0km\",\r\n                  \"geohash\": \"s7ws01wyd7ws\"\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }' | jq ''\r\n    {\r\n      \"took\": 11,\r\n      \"timed_out\": false,\r\n      \"_shards\": {\r\n        \"total\": 5,\r\n        \"successful\": 5,\r\n        \"failed\": 0\r\n      },\r\n      \"hits\": {\r\n        \"total\": 1,\r\n        \"max_score\": 1,\r\n        \"hits\": [\r\n          {\r\n            \"_index\": \"campaigns\",\r\n            \"_type\": \"campaign\",\r\n            \"_id\": \"AVFYQn4uic5h_a2BXp1k\",\r\n            \"_score\": 1,\r\n            \"_source\": {\r\n              \"id\": 12,\r\n              \"locations\": [\r\n                {\r\n                  \"id\": 13,\r\n                  \"geohash\": {\r\n                    \"geohash\": \"s7ws01wyd7ws\"\r\n                  }\r\n                }\r\n              ]\r\n            }\r\n          }\r\n        ]\r\n      }\r\n    }\r\n\r\nWhat am I missing here? The geohash query itself looks OK (response is the same when I use \"locations.geohash\" instead of \"geohash\"). The only difference is the way the query is fed to curl. Also, both versions work correctly in ES 1.4.\r\n\r\nI am not sure if this is a bug in Elasticsearch or I made some mistake in my query. Anyway, I'll be really grateful for any help!"}}