Sha256: 64110b1a72d7136c8fbc2e327fc831369c70f12cbe8f464460c1246636bfc4f3

Contents?: true

Size: 1.9 KB

Versions: 69

Compression:

Stored size: 1.9 KB

Contents

module Elasticsearch
  module API
    module Actions

      # Return query terms suggestions based on provided text and configuration.
      #
      # Pass the request definition in the `:body` argument.
      #
      # @example Return query terms suggestions ("auto-correction")
      #
      #     client.suggest index: 'myindex',
      #                    body: { my_suggest: { text: 'tset', term: { field: 'title' } } }
      #     # => { ... "my_suggest"=>[ {"text"=>"tset", ... "options"=>[{"text"=>"test", "score"=>0.75, "freq"=>5}] }]}
      #
      # @option arguments [List] :index A comma-separated list of index names to restrict the operation;
      #                                 use `_all` or empty string to perform the operation on all indices
      # @option arguments [Hash] :body The request definition
      # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
      #                                            (options: none, missing)
      # @option arguments [String] :preference Specify the node or shard the operation should be performed on
      #                                        (default: random)
      # @option arguments [String] :routing Specific routing value
      # @option arguments [String] :source The URL-encoded request definition (instead of using request body)
      #
      # @since 0.90
      #
      # @see http://elasticsearch.org/guide/reference/api/search/suggest/
      #
      def suggest(arguments={})
        valid_params = [
          :ignore_indices,
          :preference,
          :routing,
          :source ]

        method = HTTP_POST
        path   = Utils.__pathify( Utils.__listify(arguments[:index]), '_suggest' )

        params = Utils.__validate_and_extract_params arguments, valid_params
        body   = arguments[:body]

        perform_request(method, path, params, body).body
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 6 rubygems

Version Path
elasticsearch-api-1.0.16.pre lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.15 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.14 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.13 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.12 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.11 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.10 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.9 lib/elasticsearch/api/actions/suggest.rb
elasticsearch-api-1.0.7 lib/elasticsearch/api/actions/suggest.rb