|
| 1 | +module Elasticsearch |
| 2 | + module API |
| 3 | + module Actions |
| 4 | + |
| 5 | + # Return names of queries matching a document. |
| 6 | + # |
| 7 | + # Percolator allows you to register queries and then evaluate a document against them: |
| 8 | + # the IDs of matching queries are returned in the response. |
| 9 | + # |
| 10 | + # @deprecated The `_percolate` API has been deprecated in favour of a special field mapping and the |
| 11 | + # `percolate` query; |
| 12 | + # see https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_percolator.html |
| 13 | + # |
| 14 | + # See full example for Elasticsearch 5.x and higher in <https://github.com/elastic/elasticsearch-ruby/blob/master/examples/percolator/percolator_alerts.rb> |
| 15 | + # |
| 16 | + # @option arguments [String] :index The index of the document being percolated. (*Required*) |
| 17 | + # @option arguments [String] :type The type of the document being percolated. (*Required*) |
| 18 | + # @option arguments [String] :id Fetch the document specified by index/type/id and |
| 19 | + # use it instead of the passed `doc` |
| 20 | + # @option arguments [Hash] :body The percolator request definition using the percolate DSL |
| 21 | + # @option arguments [List] :routing A comma-separated list of specific routing values |
| 22 | + # @option arguments [String] :preference Specify the node or shard the operation should be performed on |
| 23 | + # (default: random) |
| 24 | + # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when |
| 25 | + # unavailable (missing or closed) |
| 26 | + # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into |
| 27 | + # no concrete indices. (This includes `_all` string or when no |
| 28 | + # indices have been specified) |
| 29 | + # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are |
| 30 | + # open, closed or both. (options: open, closed) |
| 31 | + # @option arguments [String] :percolate_index The index to percolate the document into. Defaults to passed `index`. |
| 32 | + # @option arguments [String] :percolate_format Return an array of matching query IDs instead of objects. |
| 33 | + # (options: ids) |
| 34 | + # @option arguments [String] :percolate_type The type to percolate document into. Defaults to passed `type`. |
| 35 | + # @option arguments [Number] :version Explicit version number for concurrency control |
| 36 | + # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) |
| 37 | + # |
| 38 | + # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-percolate.html |
| 39 | + # |
| 40 | + def percolate(arguments={}) |
| 41 | + Utils.__report_unsupported_method :percolate |
| 42 | + |
| 43 | + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] |
| 44 | + raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] |
| 45 | + method = HTTP_GET |
| 46 | + path = Utils.__pathify Utils.__escape(arguments[:index]), |
| 47 | + Utils.__escape(arguments[:type]), |
| 48 | + Utils.__escape(arguments[:id]), |
| 49 | + '_percolate' |
| 50 | + |
| 51 | + params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) |
| 52 | + body = arguments[:body] |
| 53 | + |
| 54 | + perform_request(method, path, params, body).body |
| 55 | + end |
| 56 | + |
| 57 | + # Register this action with its valid params when the module is loaded. |
| 58 | + # |
| 59 | + # @since 6.2.0 |
| 60 | + ParamsRegistry.register(:percolate, [ |
| 61 | + :routing, |
| 62 | + :preference, |
| 63 | + :ignore_unavailable, |
| 64 | + :allow_no_indices, |
| 65 | + :expand_wildcards, |
| 66 | + :percolate_index, |
| 67 | + :percolate_type, |
| 68 | + :percolate_format, |
| 69 | + :version, |
| 70 | + :version_type ].freeze) |
| 71 | + end |
| 72 | + end |
| 73 | +end |
0 commit comments