{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/13884","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13884/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13884/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13884/events","html_url":"https://github.com/elastic/elasticsearch/issues/13884","id":109217921,"number":13884,"title":"Bug with simple_query_string, minimum_should_match, and multiple fields.","user":{"login":"davidlbowen","id":414646,"avatar_url":"https://avatars.githubusercontent.com/u/414646?v=3","gravatar_id":"","url":"https://api.github.com/users/davidlbowen","html_url":"https://github.com/davidlbowen","followers_url":"https://api.github.com/users/davidlbowen/followers","following_url":"https://api.github.com/users/davidlbowen/following{/other_user}","gists_url":"https://api.github.com/users/davidlbowen/gists{/gist_id}","starred_url":"https://api.github.com/users/davidlbowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidlbowen/subscriptions","organizations_url":"https://api.github.com/users/davidlbowen/orgs","repos_url":"https://api.github.com/users/davidlbowen/repos","events_url":"https://api.github.com/users/davidlbowen/events{/privacy}","received_events_url":"https://api.github.com/users/davidlbowen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-01T02:34:48Z","updated_at":"2015-10-02T15:53:05Z","closed_at":null,"body":"```\r\n# With a one-word query and minimum_should_match=-50%, adding extra non-matching fields should not matter.\r\n# Tested on v1.7.2.\r\n\r\n# delete and re-create the index\r\ncurl -XDELETE localhost:9200/test\r\ncurl -XPUT localhost:9200/test\r\n\r\necho \r\n\r\n # insert a document\r\ncurl -XPUT 'http://localhost:9200/test/test/1' -d '\r\n { \"title\": \"test document\"}\r\n '\r\ncurl -XPOST 'http://localhost:9200/test/_refresh'\r\n\r\necho \r\n\r\n # this correctly finds the document (f1 is a non-existent field)\r\n curl -XGET 'http://localhost:9200/test/test/_search' -d '{\r\n  \"query\" : {\r\n    \"simple_query_string\" : {\r\n      \"fields\" : [ \"title\", \"f1\" ],\r\n      \"query\" : \"test\",\r\n      \"minimum_should_match\" : \"-50%\"\r\n    }\r\n  }\r\n }\r\n'\r\n\r\necho \r\n\r\n# this incorrectly does not find the document (f1 and f2 are non-existent fields)\r\ncurl -XGET 'http://localhost:9200/test/test/_search' -d '{\r\n  \"query\" : {\r\n    \"simple_query_string\" : {\r\n      \"fields\" : [ \"title\", \"f1\", \"f2\" ],\r\n      \"query\" : \"test\",\r\n      \"minimum_should_match\" : \"-50%\"\r\n    }\r\n  }\r\n }\r\n'\r\n\r\necho\r\n```\r\n\r\n\t\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/145069490","html_url":"https://github.com/elastic/elasticsearch/issues/13884#issuecomment-145069490","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13884","id":145069490,"user":{"login":"clintongormley","id":56599,"avatar_url":"https://avatars.githubusercontent.com/u/56599?v=3","gravatar_id":"","url":"https://api.github.com/users/clintongormley","html_url":"https://github.com/clintongormley","followers_url":"https://api.github.com/users/clintongormley/followers","following_url":"https://api.github.com/users/clintongormley/following{/other_user}","gists_url":"https://api.github.com/users/clintongormley/gists{/gist_id}","starred_url":"https://api.github.com/users/clintongormley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintongormley/subscriptions","organizations_url":"https://api.github.com/users/clintongormley/orgs","repos_url":"https://api.github.com/users/clintongormley/repos","events_url":"https://api.github.com/users/clintongormley/events{/privacy}","received_events_url":"https://api.github.com/users/clintongormley/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T15:53:05Z","updated_at":"2015-10-02T15:53:05Z","body":"This does look like a bug.  The min_should_match is being applied at the wrong level:\r\n\r\n    GET /test/test/_validate/query?explain\r\n    {\r\n      \"query\" : {\r\n        \"simple_query_string\" : {\r\n          \"fields\" : [ \"title\", \"f1\", \"f2\" ],\r\n          \"query\" : \"test\",\r\n          \"minimum_should_match\" : \"-50%\"\r\n        }\r\n      }\r\n    }\r\n\r\nReturns an explanation of:\r\n\r\n    +((f1:test title:test f2:test)~2)\r\n\r\nWhile the `query_string` and `multi_match` equivalents return:\r\n\r\n    +(title:test | f1:test | f2:test)\r\n\r\n"}}