{"action":"created","comment":{"url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/comments/22449843","id":22449843,"diff_hunk":"@@ -184,25 +282,38 @@ def search_on_elastic_search(\n \n         :param search_phrase: Searches for this particular phrase\n         :param limit: The number of records to be returned\n+        :param autocomplete: A boolean which is set to True if the request\n+        comes from the autocomplete web handler\n         :returns: `~pyes.es.ResultSet` object which contains each product's\n         attributes\n         \"\"\"\n-        # Build the query object\n-        query = cls.get_elastic_search_query(search_phrase)\n+        filterable_attributes = cls.get_filterable_attributes()\n \n-        # Wrap it in a `~pyes.query.Search` object for convenience, by calling\n-        # its search() method.\n-        search_obj = query.search()\n+        # Create the filter.\n+        main_filter = cls._build_es_filter(\n+            request, filterable_attributes=filterable_attributes\n+        )\n \n-        # If the autocomplete handler wasn't the one to send a request,\n-        # faceting can be done.\n+        # Generate the `~pyes.query.Query` object.\n+        query = cls._build_es_query(search_phrase)\n+\n+        # Now wrap the query in a `~pyes.query.Search` object for convenience.\n+        # Apply any kwargs such as filters.\n+        search_obj = query.search(filter=main_filter)\n+\n+        # Add faceting. Apply any kwargs such as filters.","path":"product.py","position":189,"original_position":189,"commit_id":"b6a5bb50d8da831d3ffdcd003562856bda90c7e0","original_commit_id":"b6a5bb50d8da831d3ffdcd003562856bda90c7e0","user":{"login":"tarunbhardwaj","id":3259423,"avatar_url":"https://avatars.githubusercontent.com/u/3259423?v=3","gravatar_id":"","url":"https://api.github.com/users/tarunbhardwaj","html_url":"https://github.com/tarunbhardwaj","followers_url":"https://api.github.com/users/tarunbhardwaj/followers","following_url":"https://api.github.com/users/tarunbhardwaj/following{/other_user}","gists_url":"https://api.github.com/users/tarunbhardwaj/gists{/gist_id}","starred_url":"https://api.github.com/users/tarunbhardwaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarunbhardwaj/subscriptions","organizations_url":"https://api.github.com/users/tarunbhardwaj/orgs","repos_url":"https://api.github.com/users/tarunbhardwaj/repos","events_url":"https://api.github.com/users/tarunbhardwaj/events{/privacy}","received_events_url":"https://api.github.com/users/tarunbhardwaj/received_events","type":"User","site_admin":false},"body":"no kwargs","created_at":"2015-01-05T07:49:15Z","updated_at":"2015-01-05T07:49:15Z","html_url":"https://github.com/openlabs/nereid-webshop-elastic-search/pull/12#discussion_r22449843","pull_request_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/comments/22449843"},"html":{"href":"https://github.com/openlabs/nereid-webshop-elastic-search/pull/12#discussion_r22449843"},"pull_request":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12","id":26594794,"html_url":"https://github.com/openlabs/nereid-webshop-elastic-search/pull/12","diff_url":"https://github.com/openlabs/nereid-webshop-elastic-search/pull/12.diff","patch_url":"https://github.com/openlabs/nereid-webshop-elastic-search/pull/12.patch","issue_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues/12","number":12,"state":"open","locked":false,"title":"Added filters to search from filterable attributes. #6543","user":{"login":"PritishC","id":1412833,"avatar_url":"https://avatars.githubusercontent.com/u/1412833?v=3","gravatar_id":"","url":"https://api.github.com/users/PritishC","html_url":"https://github.com/PritishC","followers_url":"https://api.github.com/users/PritishC/followers","following_url":"https://api.github.com/users/PritishC/following{/other_user}","gists_url":"https://api.github.com/users/PritishC/gists{/gist_id}","starred_url":"https://api.github.com/users/PritishC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PritishC/subscriptions","organizations_url":"https://api.github.com/users/PritishC/orgs","repos_url":"https://api.github.com/users/PritishC/repos","events_url":"https://api.github.com/users/PritishC/events{/privacy}","received_events_url":"https://api.github.com/users/PritishC/received_events","type":"User","site_admin":false},"body":"* Added a test for filtering and facet tally updation on filtering. Filters are applied to the facets as well.\r\n* If an attribute is filterable, additional settings can be configured for it, such as displaying the facet counts, multi-selection of attribute values, etc.\r\n* Added a boolean parameter to prevent faceting on autocomplete request.\r\n* Added a template filter to append display_count values to facets.\r\n\r\nFor reference: [SO Thread](http://stackoverflow.com/questions/12399326/convert-the-facet-filter-query-into-pyes-format)","created_at":"2014-12-26T09:10:27Z","updated_at":"2015-01-05T07:49:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fc38e16e7860b8e12d5590c07aed7ca9c194820","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12/commits","review_comments_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12/comments","review_comment_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/comments/{number}","comments_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues/12/comments","statuses_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/statuses/b6a5bb50d8da831d3ffdcd003562856bda90c7e0","head":{"label":"PritishC:feature/task-6543","ref":"feature/task-6543","sha":"b6a5bb50d8da831d3ffdcd003562856bda90c7e0","user":{"login":"PritishC","id":1412833,"avatar_url":"https://avatars.githubusercontent.com/u/1412833?v=3","gravatar_id":"","url":"https://api.github.com/users/PritishC","html_url":"https://github.com/PritishC","followers_url":"https://api.github.com/users/PritishC/followers","following_url":"https://api.github.com/users/PritishC/following{/other_user}","gists_url":"https://api.github.com/users/PritishC/gists{/gist_id}","starred_url":"https://api.github.com/users/PritishC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PritishC/subscriptions","organizations_url":"https://api.github.com/users/PritishC/orgs","repos_url":"https://api.github.com/users/PritishC/repos","events_url":"https://api.github.com/users/PritishC/events{/privacy}","received_events_url":"https://api.github.com/users/PritishC/received_events","type":"User","site_admin":false},"repo":{"id":27475363,"name":"nereid-webshop-elastic-search","full_name":"PritishC/nereid-webshop-elastic-search","owner":{"login":"PritishC","id":1412833,"avatar_url":"https://avatars.githubusercontent.com/u/1412833?v=3","gravatar_id":"","url":"https://api.github.com/users/PritishC","html_url":"https://github.com/PritishC","followers_url":"https://api.github.com/users/PritishC/followers","following_url":"https://api.github.com/users/PritishC/following{/other_user}","gists_url":"https://api.github.com/users/PritishC/gists{/gist_id}","starred_url":"https://api.github.com/users/PritishC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PritishC/subscriptions","organizations_url":"https://api.github.com/users/PritishC/orgs","repos_url":"https://api.github.com/users/PritishC/repos","events_url":"https://api.github.com/users/PritishC/events{/privacy}","received_events_url":"https://api.github.com/users/PritishC/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PritishC/nereid-webshop-elastic-search","description":"","fork":true,"url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search","forks_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/forks","keys_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/teams","hooks_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/hooks","issue_events_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/issues/events{/number}","events_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/events","assignees_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/assignees{/user}","branches_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/branches{/branch}","tags_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/tags","blobs_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/git/refs{/sha}","trees_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/statuses/{sha}","languages_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/languages","stargazers_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/stargazers","contributors_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/contributors","subscribers_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/subscribers","subscription_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/subscription","commits_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/commits{/sha}","git_commits_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/git/commits{/sha}","comments_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/comments{/number}","issue_comment_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/issues/comments/{number}","contents_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/contents/{+path}","compare_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/merges","archive_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/downloads","issues_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/issues{/number}","pulls_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/pulls{/number}","milestones_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/milestones{/number}","notifications_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/labels{/name}","releases_url":"https://api.github.com/repos/PritishC/nereid-webshop-elastic-search/releases{/id}","created_at":"2014-12-03T07:39:35Z","updated_at":"2014-12-03T07:39:38Z","pushed_at":"2015-01-05T07:19:59Z","git_url":"git://github.com/PritishC/nereid-webshop-elastic-search.git","ssh_url":"git@github.com:PritishC/nereid-webshop-elastic-search.git","clone_url":"https://github.com/PritishC/nereid-webshop-elastic-search.git","svn_url":"https://github.com/PritishC/nereid-webshop-elastic-search","homepage":null,"size":465,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"openlabs:develop","ref":"develop","sha":"7730cfb15dc5d41f9fa502ed4a6ad44bdb191f53","user":{"login":"openlabs","id":777983,"avatar_url":"https://avatars.githubusercontent.com/u/777983?v=3","gravatar_id":"","url":"https://api.github.com/users/openlabs","html_url":"https://github.com/openlabs","followers_url":"https://api.github.com/users/openlabs/followers","following_url":"https://api.github.com/users/openlabs/following{/other_user}","gists_url":"https://api.github.com/users/openlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/openlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openlabs/subscriptions","organizations_url":"https://api.github.com/users/openlabs/orgs","repos_url":"https://api.github.com/users/openlabs/repos","events_url":"https://api.github.com/users/openlabs/events{/privacy}","received_events_url":"https://api.github.com/users/openlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":26112951,"name":"nereid-webshop-elastic-search","full_name":"openlabs/nereid-webshop-elastic-search","owner":{"login":"openlabs","id":777983,"avatar_url":"https://avatars.githubusercontent.com/u/777983?v=3","gravatar_id":"","url":"https://api.github.com/users/openlabs","html_url":"https://github.com/openlabs","followers_url":"https://api.github.com/users/openlabs/followers","following_url":"https://api.github.com/users/openlabs/following{/other_user}","gists_url":"https://api.github.com/users/openlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/openlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openlabs/subscriptions","organizations_url":"https://api.github.com/users/openlabs/orgs","repos_url":"https://api.github.com/users/openlabs/repos","events_url":"https://api.github.com/users/openlabs/events{/privacy}","received_events_url":"https://api.github.com/users/openlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openlabs/nereid-webshop-elastic-search","description":"Elastic seach powered full text search for Nereid Webshop","fork":false,"url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search","forks_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/forks","keys_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/teams","hooks_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/hooks","issue_events_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues/events{/number}","events_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/events","assignees_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/assignees{/user}","branches_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/branches{/branch}","tags_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/tags","blobs_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/git/refs{/sha}","trees_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/statuses/{sha}","languages_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/languages","stargazers_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/stargazers","contributors_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/contributors","subscribers_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/subscribers","subscription_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/subscription","commits_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/commits{/sha}","git_commits_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/git/commits{/sha}","comments_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/comments{/number}","issue_comment_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues/comments/{number}","contents_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/contents/{+path}","compare_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/merges","archive_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/downloads","issues_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues{/number}","pulls_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls{/number}","milestones_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/milestones{/number}","notifications_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/labels{/name}","releases_url":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/releases{/id}","created_at":"2014-11-03T09:59:27Z","updated_at":"2015-01-05T07:11:35Z","pushed_at":"2015-01-05T07:11:35Z","git_url":"git://github.com/openlabs/nereid-webshop-elastic-search.git","ssh_url":"git@github.com:openlabs/nereid-webshop-elastic-search.git","clone_url":"https://github.com/openlabs/nereid-webshop-elastic-search.git","svn_url":"https://github.com/openlabs/nereid-webshop-elastic-search","homepage":"","size":477,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12"},"html":{"href":"https://github.com/openlabs/nereid-webshop-elastic-search/pull/12"},"issue":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues/12"},"comments":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/openlabs/nereid-webshop-elastic-search/statuses/b6a5bb50d8da831d3ffdcd003562856bda90c7e0"}}}}