{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/10590","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10590/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10590/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10590/events","html_url":"https://github.com/elastic/elasticsearch/issues/10590","id":68315377,"number":10590,"title":"Missing field filter not working","user":{"login":"dling","id":541984,"avatar_url":"https://avatars.githubusercontent.com/u/541984?v=3","gravatar_id":"","url":"https://api.github.com/users/dling","html_url":"https://github.com/dling","followers_url":"https://api.github.com/users/dling/followers","following_url":"https://api.github.com/users/dling/following{/other_user}","gists_url":"https://api.github.com/users/dling/gists{/gist_id}","starred_url":"https://api.github.com/users/dling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dling/subscriptions","organizations_url":"https://api.github.com/users/dling/orgs","repos_url":"https://api.github.com/users/dling/repos","events_url":"https://api.github.com/users/dling/events{/privacy}","received_events_url":"https://api.github.com/users/dling/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/feedback_needed","name":"feedback_needed","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-14T09:26:26Z","updated_at":"2015-04-21T14:19:11Z","closed_at":null,"body":"I have an Elasticsearch 1.5.0 environment with 3 nodes and 3 shards of each index.\r\n\r\nI have the following document indexed:\r\n\r\n```json\r\n{\r\n  \"_index\": \"content-1\",\r\n  \"_type\": \"share-site-article\",\r\n  \"_id\": \"5c7aca72-f1fd-48dd-b2ee-1ed6d3ef134b\",\r\n  \"_source\": {\r\n    \"preamble\": \"X and Y presents\",\r\n    \"nativeAdCampaignName\": \"Company\",\r\n    \"_site\": \"docs\"\r\n  }\r\n}\r\n```\r\n\r\nHowever when I make queries and combine it with using the missing field filter the actual missing field filter is not being used.\r\n\r\n```json\r\nPOST /content/_search\r\n{\r\n    \"query\": {\r\n     \"match\": {\r\n        \"_all\": \"X and Y presents\"\r\n    }\r\n   },\r\n   \"filter\": {\r\n      \"and\": {\r\n         \"filters\": [\r\n            {\r\n               \"missing\": {\r\n                  \"field\": \"nativeAdCampaignName\"\r\n               }\r\n            },             \r\n            {\r\n               \"term\": {\r\n                  \"_id\": \"5c7aca72-f1fd-48dd-b2ee-1ed6d3ef134b\"\r\n               }\r\n            },\r\n            {\r\n               \"term\": {\r\n                  \"_site\": \"docs\"\r\n               }\r\n            }\r\n         ]\r\n      }\r\n   }\r\n}\r\n```\r\n\r\n\r\nResponse output for that query:\r\n\r\n```json\r\n {\r\n   \"took\": 38,\r\n   \"timed_out\": false,\r\n   \"_shards\": {\r\n      \"total\": 6,\r\n      \"successful\": 6,\r\n      \"failed\": 0\r\n   },\r\n   \"hits\": {\r\n      \"total\": 1,\r\n      \"max_score\": 1.8740479,\r\n      \"hits\": [\r\n         {\r\n            \"_index\": \"content-1\",\r\n            \"_type\": \"share-site-article\",\r\n            \"_id\": \"5c7aca72-f1fd-48dd-b2ee-1ed6d3ef134b\",\r\n            \"_score\": 1.8740479,\r\n            \"_source\": {\r\n               \"preamble\": \"X and Y presents\",\r\n               \"nativeAdCampaignName\": \"Company\",\r\n               \"_site\": \"docs\"\r\n            }\r\n         }\r\n      ]\r\n   }\r\n}\r\n```\r\n\r\nThe query above should not return the document, since I am querying for document that has missing field values in the specific field 'nativeAdCampaignName'.\r\n\r\nThe field I'm unable to use with missing field is indeed indexed, i.e. I can search on that field and have the document returned.\r\n\r\n(A problematic implication is that I cannot reproduce this problem in a local single-node environment running same ES version and mapping. There's different JVM versions and difference in number of nodes though.)\r\n\r\nThis environment runs on OpenJDK 64-Bit Server VM, 1.7.0_75.\r\n\r\nAny ideas why this happens?"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/94811328","html_url":"https://github.com/elastic/elasticsearch/issues/10590#issuecomment-94811328","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10590","id":94811328,"user":{"login":"HenleyChiu","id":788695,"avatar_url":"https://avatars.githubusercontent.com/u/788695?v=3","gravatar_id":"","url":"https://api.github.com/users/HenleyChiu","html_url":"https://github.com/HenleyChiu","followers_url":"https://api.github.com/users/HenleyChiu/followers","following_url":"https://api.github.com/users/HenleyChiu/following{/other_user}","gists_url":"https://api.github.com/users/HenleyChiu/gists{/gist_id}","starred_url":"https://api.github.com/users/HenleyChiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HenleyChiu/subscriptions","organizations_url":"https://api.github.com/users/HenleyChiu/orgs","repos_url":"https://api.github.com/users/HenleyChiu/repos","events_url":"https://api.github.com/users/HenleyChiu/events{/privacy}","received_events_url":"https://api.github.com/users/HenleyChiu/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T14:19:10Z","updated_at":"2015-04-21T14:19:10Z","body":"@dling I'm not sure if you're lucky, but as a workaround, you can replace the missing filter with a bool filter. This is only if you know the value can be from a limited set of possible values.\r\n\r\n\"filter\":{\t\"bool\" : {\r\n                \"must_not\" : [\r\n                    {\r\n                        \"term\" : { \"nativeAdCampaignName\" : \"VALUE\" }\r\n                    }\r\n                ]\r\n            }\r\n    }"}}