{"action":"created","comment":{"url":"https://api.github.com/repos/github/elastomer-client/pulls/comments/40232227","id":40232227,"diff_hunk":"@@ -0,0 +1,127 @@\n+module Elastomer\n+  class Client\n+\n+    # Execute an array of percolate actions in bulk. Results are returned in an\n+    # array in the order the actions were sent.\n+    #\n+    # The `multi_percolate` method can be used in two ways. Without a block\n+    # the method will perform an API call, and it requires a bulk request\n+    # body and optional request parameters.\n+    #\n+    # See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html#_multi_percolate_api\n+    #\n+    # body   - Request body as a String (required if a block is not given)\n+    # params - Optional request parameters as a Hash\n+    # block  - Passed to a MultiPercolate instance which assembles the\n+    #          percolate actions into a single request.\n+    #\n+    # Examples\n+    #\n+    #   # index and type in request body\n+    #   multi_percolate(request_body)\n+    #\n+    #   # index in URI\n+    #   multi_percolate(request_body, :index => 'default-index')\n+    #\n+    #   # block form\n+    #   multi_percolate(:index => 'default-index') do |m|\n+    #     m.percolate({ :author => \"pea53\" }, { :type => 'default-type' })\n+    #     m.count({ :author => \"pea53\" }, { :type => 'type2' })\n+    #     ...\n+    #   end\n+    #\n+    # Returns the response body as a Hash\n+    def multi_percolate(body = nil, params = nil)\n+      if block_given?\n+        params, body = (body || {}), nil\n+        yield mpercolate_obj = MultiPercolate.new(self, params)\n+        mpercolate_obj.call\n+      else\n+        raise 'multi_percolate request body cannot be nil' if body.nil?\n+        params ||= {}\n+\n+        response = self.post '{/index}{/type}/_mpercolate', params.merge(:body => body)\n+        response.body\n+      end\n+    end\n+    alias_method :mpercolate, :multi_percolate\n+\n+    # The MultiPercolate class is a helper for accumulating and submitting\n+    # multi_percolate API requests. Instances of the MultiPercolate class\n+    # accumulate percolate actions and then issue a single API request to\n+    # Elasticsearch, which runs all accumulated percolate actions in parallel\n+    # and returns each result hash aggregated into an array of result\n+    # hashes.\n+    #\n+    # Instead of instantiating this class directly, use\n+    # the block form of Client#multi_percolate.\n+    #\n+    class MultiPercolate\n+\n+      # Create a new MultiPercolate instance for accumulating percolate actions\n+      # and submitting them all as a single request.\n+      #\n+      # client - Elastomer::Client used for HTTP requests to the server\n+      # params - Parameters Hash to pass to the Client#multi_percolate method\n+      def initialize(client, params = {})\n+        @client  = client\n+        @params  = params\n+\n+        @actions = []\n+      end\n+\n+      attr_reader :client\n+\n+      # Add a percolate action to the multi percolate request. This percolate\n+      # action will not be executed until the multi_percolate API call is made.\n+      #\n+      # header - A Hash of the index and type, if not provided in the params\n+      # doc    - A Hash of the document\n+      #\n+      # Returns this MultiPercolate instance.\n+      def percolate(doc, header = {})\n+        add_to_actions(:percolate => header)\n+        add_to_actions(:doc => doc)\n+      end\n+\n+      # Add a percolate acount action to the multi percolate request. This\n+      # percolate count action will not be executed until the multi_percolate\n+      # API call is made.\n+      #\n+      # header - A Hash of the index and type, if not provided in the params\n+      # doc    - A Hash of the document\n+      #\n+      # Returns this MultiPercolate instance.\n+      def count(header, doc)","path":"lib/elastomer/client/multi_percolate.rb","position":95,"original_position":95,"commit_id":"b63a5e2cb42a0ffe9dc74437bc8e520a27666cb1","original_commit_id":"b63a5e2cb42a0ffe9dc74437bc8e520a27666cb1","user":{"login":"grantr","id":680,"avatar_url":"https://avatars.githubusercontent.com/u/680?v=3","gravatar_id":"","url":"https://api.github.com/users/grantr","html_url":"https://github.com/grantr","followers_url":"https://api.github.com/users/grantr/followers","following_url":"https://api.github.com/users/grantr/following{/other_user}","gists_url":"https://api.github.com/users/grantr/gists{/gist_id}","starred_url":"https://api.github.com/users/grantr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grantr/subscriptions","organizations_url":"https://api.github.com/users/grantr/orgs","repos_url":"https://api.github.com/users/grantr/repos","events_url":"https://api.github.com/users/grantr/events{/privacy}","received_events_url":"https://api.github.com/users/grantr/received_events","type":"User","site_admin":true},"body":"Reverse argument order to match `percolate`","created_at":"2015-09-23T17:30:11Z","updated_at":"2015-09-23T17:30:11Z","html_url":"https://github.com/github/elastomer-client/pull/113#discussion_r40232227","pull_request_url":"https://api.github.com/repos/github/elastomer-client/pulls/113","_links":{"self":{"href":"https://api.github.com/repos/github/elastomer-client/pulls/comments/40232227"},"html":{"href":"https://github.com/github/elastomer-client/pull/113#discussion_r40232227"},"pull_request":{"href":"https://api.github.com/repos/github/elastomer-client/pulls/113"}}},"pull_request":{"url":"https://api.github.com/repos/github/elastomer-client/pulls/113","id":45361834,"html_url":"https://github.com/github/elastomer-client/pull/113","diff_url":"https://github.com/github/elastomer-client/pull/113.diff","patch_url":"https://github.com/github/elastomer-client/pull/113.patch","issue_url":"https://api.github.com/repos/github/elastomer-client/issues/113","number":113,"state":"open","locked":false,"title":"Implement the percolate API","user":{"login":"chrismwendt","id":1387653,"avatar_url":"https://avatars.githubusercontent.com/u/1387653?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismwendt","html_url":"https://github.com/chrismwendt","followers_url":"https://api.github.com/users/chrismwendt/followers","following_url":"https://api.github.com/users/chrismwendt/following{/other_user}","gists_url":"https://api.github.com/users/chrismwendt/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismwendt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismwendt/subscriptions","organizations_url":"https://api.github.com/users/chrismwendt/orgs","repos_url":"https://api.github.com/users/chrismwendt/repos","events_url":"https://api.github.com/users/chrismwendt/events{/privacy}","received_events_url":"https://api.github.com/users/chrismwendt/received_events","type":"User","site_admin":true},"body":"This looked like low hanging fruit, so I decided to give it a shot. \"Percolate API\" #24 is the motivating issue.\r\n\r\n- [x] Create/Retrieve/Delete/Exists on percolators\r\n- [x] Percolate new document\r\n- [x] Percolate existing document\r\n- [x] Percolate count new and existing [docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html#_percolator_count_api)\r\n- [x] Multi percolate [docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html#_multi_percolate_api)","created_at":"2015-09-18T01:53:34Z","updated_at":"2015-09-23T17:30:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa221af71811ec9bb65f2564f670a7c1546ede02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/github/elastomer-client/pulls/113/commits","review_comments_url":"https://api.github.com/repos/github/elastomer-client/pulls/113/comments","review_comment_url":"https://api.github.com/repos/github/elastomer-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/github/elastomer-client/issues/113/comments","statuses_url":"https://api.github.com/repos/github/elastomer-client/statuses/b63a5e2cb42a0ffe9dc74437bc8e520a27666cb1","head":{"label":"github:percolator","ref":"percolator","sha":"b63a5e2cb42a0ffe9dc74437bc8e520a27666cb1","user":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"repo":{"id":6180360,"name":"elastomer-client","full_name":"github/elastomer-client","owner":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/github/elastomer-client","description":"A library for interacting with Elasticsearch","fork":false,"url":"https://api.github.com/repos/github/elastomer-client","forks_url":"https://api.github.com/repos/github/elastomer-client/forks","keys_url":"https://api.github.com/repos/github/elastomer-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/elastomer-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/elastomer-client/teams","hooks_url":"https://api.github.com/repos/github/elastomer-client/hooks","issue_events_url":"https://api.github.com/repos/github/elastomer-client/issues/events{/number}","events_url":"https://api.github.com/repos/github/elastomer-client/events","assignees_url":"https://api.github.com/repos/github/elastomer-client/assignees{/user}","branches_url":"https://api.github.com/repos/github/elastomer-client/branches{/branch}","tags_url":"https://api.github.com/repos/github/elastomer-client/tags","blobs_url":"https://api.github.com/repos/github/elastomer-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/elastomer-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/elastomer-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/elastomer-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/elastomer-client/statuses/{sha}","languages_url":"https://api.github.com/repos/github/elastomer-client/languages","stargazers_url":"https://api.github.com/repos/github/elastomer-client/stargazers","contributors_url":"https://api.github.com/repos/github/elastomer-client/contributors","subscribers_url":"https://api.github.com/repos/github/elastomer-client/subscribers","subscription_url":"https://api.github.com/repos/github/elastomer-client/subscription","commits_url":"https://api.github.com/repos/github/elastomer-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/elastomer-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/elastomer-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/elastomer-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/elastomer-client/contents/{+path}","compare_url":"https://api.github.com/repos/github/elastomer-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/elastomer-client/merges","archive_url":"https://api.github.com/repos/github/elastomer-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/elastomer-client/downloads","issues_url":"https://api.github.com/repos/github/elastomer-client/issues{/number}","pulls_url":"https://api.github.com/repos/github/elastomer-client/pulls{/number}","milestones_url":"https://api.github.com/repos/github/elastomer-client/milestones{/number}","notifications_url":"https://api.github.com/repos/github/elastomer-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/elastomer-client/labels{/name}","releases_url":"https://api.github.com/repos/github/elastomer-client/releases{/id}","created_at":"2012-10-11T20:33:17Z","updated_at":"2015-09-18T04:44:02Z","pushed_at":"2015-09-23T17:25:44Z","git_url":"git://github.com/github/elastomer-client.git","ssh_url":"git@github.com:github/elastomer-client.git","clone_url":"https://github.com/github/elastomer-client.git","svn_url":"https://github.com/github/elastomer-client","homepage":"","size":2241,"stargazers_count":79,"watchers_count":79,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":14,"forks":3,"open_issues":14,"watchers":79,"default_branch":"master"}},"base":{"label":"github:master","ref":"master","sha":"a931502294e86f33a791c90731dc9b54370e9ba3","user":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"repo":{"id":6180360,"name":"elastomer-client","full_name":"github/elastomer-client","owner":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/github/elastomer-client","description":"A library for interacting with Elasticsearch","fork":false,"url":"https://api.github.com/repos/github/elastomer-client","forks_url":"https://api.github.com/repos/github/elastomer-client/forks","keys_url":"https://api.github.com/repos/github/elastomer-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/elastomer-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/elastomer-client/teams","hooks_url":"https://api.github.com/repos/github/elastomer-client/hooks","issue_events_url":"https://api.github.com/repos/github/elastomer-client/issues/events{/number}","events_url":"https://api.github.com/repos/github/elastomer-client/events","assignees_url":"https://api.github.com/repos/github/elastomer-client/assignees{/user}","branches_url":"https://api.github.com/repos/github/elastomer-client/branches{/branch}","tags_url":"https://api.github.com/repos/github/elastomer-client/tags","blobs_url":"https://api.github.com/repos/github/elastomer-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/elastomer-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/elastomer-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/elastomer-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/elastomer-client/statuses/{sha}","languages_url":"https://api.github.com/repos/github/elastomer-client/languages","stargazers_url":"https://api.github.com/repos/github/elastomer-client/stargazers","contributors_url":"https://api.github.com/repos/github/elastomer-client/contributors","subscribers_url":"https://api.github.com/repos/github/elastomer-client/subscribers","subscription_url":"https://api.github.com/repos/github/elastomer-client/subscription","commits_url":"https://api.github.com/repos/github/elastomer-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/elastomer-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/elastomer-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/elastomer-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/elastomer-client/contents/{+path}","compare_url":"https://api.github.com/repos/github/elastomer-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/elastomer-client/merges","archive_url":"https://api.github.com/repos/github/elastomer-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/elastomer-client/downloads","issues_url":"https://api.github.com/repos/github/elastomer-client/issues{/number}","pulls_url":"https://api.github.com/repos/github/elastomer-client/pulls{/number}","milestones_url":"https://api.github.com/repos/github/elastomer-client/milestones{/number}","notifications_url":"https://api.github.com/repos/github/elastomer-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/elastomer-client/labels{/name}","releases_url":"https://api.github.com/repos/github/elastomer-client/releases{/id}","created_at":"2012-10-11T20:33:17Z","updated_at":"2015-09-18T04:44:02Z","pushed_at":"2015-09-23T17:25:44Z","git_url":"git://github.com/github/elastomer-client.git","ssh_url":"git@github.com:github/elastomer-client.git","clone_url":"https://github.com/github/elastomer-client.git","svn_url":"https://github.com/github/elastomer-client","homepage":"","size":2241,"stargazers_count":79,"watchers_count":79,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":14,"forks":3,"open_issues":14,"watchers":79,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/github/elastomer-client/pulls/113"},"html":{"href":"https://github.com/github/elastomer-client/pull/113"},"issue":{"href":"https://api.github.com/repos/github/elastomer-client/issues/113"},"comments":{"href":"https://api.github.com/repos/github/elastomer-client/issues/113/comments"},"review_comments":{"href":"https://api.github.com/repos/github/elastomer-client/pulls/113/comments"},"review_comment":{"href":"https://api.github.com/repos/github/elastomer-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/github/elastomer-client/pulls/113/commits"},"statuses":{"href":"https://api.github.com/repos/github/elastomer-client/statuses/b63a5e2cb42a0ffe9dc74437bc8e520a27666cb1"}}}}