{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/15417","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15417/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15417/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15417/events","html_url":"https://github.com/elastic/elasticsearch/issues/15417","id":122024774,"number":15417,"title":"ATLEAST  query ","user":{"login":"ESamir","id":9035864,"avatar_url":"https://avatars.githubusercontent.com/u/9035864?v=3","gravatar_id":"","url":"https://api.github.com/users/ESamir","html_url":"https://github.com/ESamir","followers_url":"https://api.github.com/users/ESamir/followers","following_url":"https://api.github.com/users/ESamir/following{/other_user}","gists_url":"https://api.github.com/users/ESamir/gists{/gist_id}","starred_url":"https://api.github.com/users/ESamir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESamir/subscriptions","organizations_url":"https://api.github.com/users/ESamir/orgs","repos_url":"https://api.github.com/users/ESamir/repos","events_url":"https://api.github.com/users/ESamir/events{/privacy}","received_events_url":"https://api.github.com/users/ESamir/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Query%20DSL","name":":Query DSL","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/feature","name":"feature","color":"328a58"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-14T11:29:26Z","updated_at":"2015-12-14T11:42:03Z","closed_at":"2015-12-14T11:42:03Z","body":"Customer will like a new type of query \r\n\r\nWe can call it \"ATLEAST\" query it will look for all documents which contain at least N times a specific term \r\n \r\nlike find all the document that Atleast contain the term Paris 5 times ."},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/164416827","html_url":"https://github.com/elastic/elasticsearch/issues/15417#issuecomment-164416827","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15417","id":164416827,"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-12-14T11:42:03Z","updated_at":"2015-12-14T11:42:03Z","body":"This can be done very easily today. \r\n\r\n    PUT t/t/1\r\n    {\r\n      \"text\":\"Paris is Paris and so is Paris\"\r\n    }\r\n    \r\n The first method is a bit of a hack using the phrase query:\r\n\r\n    GET t/_search\r\n    {\r\n      \"query\": {\r\n        \"constant_score\": {\r\n          \"filter\": {\r\n            \"match_phrase\": {\r\n              \"text\": {\r\n                \"query\": \"Paris Paris Paris\",\r\n                \"slop\": 1000\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n    \r\nThe second method using scripting will probably perform better:\r\n\r\n    GET t/_search\r\n    {\r\n      \"query\": {\r\n        \"constant_score\": {\r\n          \"filter\": {\r\n            \"script\": {\r\n              \"script\": {\r\n                \"inline\": \"_index[field][term].tf() >= required\",\r\n                \"params\": {\r\n                  \"field\": \"text\",\r\n                  \"term\": \"paris\",\r\n                  \"required\": 3\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }"}}