Module: Elasticsearch::API::Actions
- Defined in:
- lib/elasticsearch/api/actions/get.rb,
lib/elasticsearch/api/actions/mlt.rb,
lib/elasticsearch/api/actions/bulk.rb,
lib/elasticsearch/api/actions/info.rb,
lib/elasticsearch/api/actions/mget.rb,
lib/elasticsearch/api/actions/ping.rb,
lib/elasticsearch/api/actions/count.rb,
lib/elasticsearch/api/actions/index.rb,
lib/elasticsearch/api/actions/create.rb,
lib/elasticsearch/api/actions/delete.rb,
lib/elasticsearch/api/actions/exists.rb,
lib/elasticsearch/api/actions/scroll.rb,
lib/elasticsearch/api/actions/search.rb,
lib/elasticsearch/api/actions/update.rb,
lib/elasticsearch/api/actions/explain.rb,
lib/elasticsearch/api/actions/msearch.rb,
lib/elasticsearch/api/actions/suggest.rb,
lib/elasticsearch/api/actions/percolate.rb,
lib/elasticsearch/api/actions/get_source.rb,
lib/elasticsearch/api/actions/mpercolate.rb,
lib/elasticsearch/api/actions/termvector.rb,
lib/elasticsearch/api/actions/clear_scroll.rb,
lib/elasticsearch/api/actions/mtermvectors.rb,
lib/elasticsearch/api/actions/count_percolate.rb,
lib/elasticsearch/api/actions/delete_by_query.rb
Instance Method Summary collapse
-
#bulk(arguments = {}) ⇒ Hash
Perform multiple index, delete or update operations in a single request.
-
#clear_scroll(arguments = {}) ⇒ Object
Abort a particular scroll search and clear all the resources associated with it.
-
#count(arguments = {}) ⇒ Object
Get the number of documents for the cluster, index, type, or a query.
-
#count_percolate(arguments = {}) ⇒ Object
Return the number of queries matching a document.
-
#create(arguments = {}) ⇒ Object
Create a document.
-
#delete(arguments = {}) ⇒ Object
Delete a single document.
-
#delete_by_query(arguments = {}) ⇒ Object
Delete documents which match specified query.
-
#exists(arguments = {}) ⇒ Object
Return true if the specified document exists, false otherwise.
-
#explain(arguments = {}) ⇒ Object
Return information if and how well a document matches a query.
-
#get(arguments = {}) ⇒ Object
Return a specified document.
-
#get_source(arguments = {}) ⇒ Object
Return a specified document’s ‘_source`.
-
#index(arguments = {}) ⇒ Object
Create or update a document.
-
#info(arguments = {}) ⇒ Object
Return simple information about the cluster (name, version).
-
#mget(arguments = {}) ⇒ Object
Return multiple documents from one or more indices in a single request.
-
#mlt(arguments = {}) ⇒ Object
Return documents similar to the specified one.
-
#mpercolate(arguments = {}) ⇒ Object
Perform multiple percolate operations in a single request, similar to the #msearch API.
-
#msearch(arguments = {}) ⇒ Object
Perform multiple search operations in a single request.
-
#mtermvectors(arguments = {}) ⇒ Object
Returns information and statistics about terms in the fields of multiple documents in a single request/response.
-
#percolate(arguments = {}) ⇒ Object
Return names of queries matching a document.
-
#ping(arguments = {}) ⇒ Object
Returns true if the cluster returns a sucessfull HTTP response, false otherwise.
-
#scroll(arguments = {}) ⇒ Object
Efficiently iterate over a large result set.
-
#search(arguments = {}) ⇒ Hash
Return documents matching a query, as well as aggregations (facets), highlighted snippets, suggestions, etc.
-
#suggest(arguments = {}) ⇒ Object
Return query terms suggestions based on provided text and configuration.
-
#termvector(arguments = {}) ⇒ Object
Return information and statistics about terms in the fields of a particular document.
-
#update(arguments = {}) ⇒ Object
Update a document without sending the whole document in the request (“partial update”).
Instance Method Details
#bulk(arguments = {}) ⇒ Hash
Perform multiple index, delete or update operations in a single request.
Pass the operations in the ‘:body` option as an array of hashes, following Elasticsearch conventions. For operations which take data, pass them as the `:data` option in the operation hash.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/elasticsearch/api/actions/bulk.rb', line 61 def bulk(arguments={}) valid_params = [ :consistency, :refresh, :replication, :type, :timeout ] method = 'POST' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), '_bulk' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] if body.is_a? Array payload = Utils.__bulkify(body) else payload = body end perform_request(method, path, params, payload).body end |
#clear_scroll(arguments = {}) ⇒ Object
Abort a particular scroll search and clear all the resources associated with it.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/elasticsearch/api/actions/clear_scroll.rb', line 12 def clear_scroll(arguments={}) raise ArgumentError, "Required argument 'scroll_id' missing" unless arguments[:scroll_id] method = 'DELETE' path = Utils.__pathify '_search/scroll', Utils.__listify(arguments[:scroll_id]) params = {} body = nil perform_request(method, path, params, body).body end |
#count(arguments = {}) ⇒ Object
Get the number of documents for the cluster, index, type, or a query.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/elasticsearch/api/actions/count.rb', line 37 def count(arguments={}) valid_params = [ :ignore_indices, :ignore_unavailable, :allow_no_indices, :expand_wildcards, :min_score, :preference, :routing, :source ] method = 'GET' path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_count' ) params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#count_percolate(arguments = {}) ⇒ Object
Return the number of queries matching a document.
Percolator allows you to register queries and then evaluate a document against them: the number of matching queries is returned in the response.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/elasticsearch/api/actions/count_percolate.rb', line 51 def count_percolate(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] valid_params = [ :routing, :preference, :ignore_unavailable, :allow_no_indices, :expand_wildcards, :percolate_index, :percolate_type, :version, :version_type ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), arguments[:id], '_percolate/count' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#create(arguments = {}) ⇒ Object
Create a document.
Enforce the create operation when indexing a document – the operation will return an error when the document already exists.
(The ‘:op_type` argument is ignored.)
29 30 31 |
# File 'lib/elasticsearch/api/actions/create.rb', line 29 def create(arguments={}) index arguments.update :op_type => 'create' end |
#delete(arguments = {}) ⇒ Object
Delete a single document.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/elasticsearch/api/actions/delete.rb', line 31 def delete(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] valid_params = [ :consistency, :parent, :refresh, :replication, :routing, :timeout, :version, :version_type ] method = 'DELETE' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]) params = Utils.__validate_and_extract_params arguments, valid_params body = nil perform_request(method, path, params, body).body rescue Exception => e # NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false else raise(e) end end |
#delete_by_query(arguments = {}) ⇒ Object
Delete documents which match specified query.
Provide the query either as a “query string” query in the ‘:q` argument, or using the Elasticsearch’s [Query DSL](www.elasticsearch.org/guide/reference/query-dsl/) in the ‘:body` argument.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/elasticsearch/api/actions/delete_by_query.rb', line 45 def delete_by_query(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] valid_params = [ :analyzer, :consistency, :default_operator, :df, :ignore_indices, :ignore_unavailable, :allow_no_indices, :expand_wildcards, :replication, :q, :routing, :source, :timeout ] method = 'DELETE' path = Utils.__pathify Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '/_query' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#exists(arguments = {}) ⇒ Object
Return true if the specified document exists, false otherwise.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/elasticsearch/api/actions/exists.rb', line 23 def exists(arguments={}) raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments[:type] ||= '_all' valid_params = [ :parent, :preference, :realtime, :refresh, :routing ] method = 'HEAD' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]) params = Utils.__validate_and_extract_params arguments, valid_params body = nil perform_request(method, path, params, body).status == 200 ? true : false rescue Exception => e if e.class.to_s =~ /NotFound/ || e. =~ /Not\s*Found|404/i false else raise e end end |
#explain(arguments = {}) ⇒ Object
Return information if and how well a document matches a query.
The returned information contains a ‘_score` and its explanation, if the document matches the query.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/elasticsearch/api/actions/explain.rb', line 45 def explain(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] valid_params = [ :analyze_wildcard, :analyzer, :default_operator, :df, :fields, :lenient, :lowercase_expanded_terms, :parent, :preference, :q, :routing, :source, :_source, :_source_include, :_source_exclude ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]), '_explain' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] params[:fields] = Utils.__listify(params[:fields]) if params[:fields] perform_request(method, path, params, body).body end |
#get(arguments = {}) ⇒ Object
Return a specified document.
The response contains full document, as stored in Elasticsearch, incl. ‘_source`, `_version`, etc.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/elasticsearch/api/actions/get.rb', line 32 def get(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments[:type] ||= '_all' valid_params = [ :fields, :parent, :preference, :realtime, :refresh, :routing, :_source, :_source_include, :_source_exclude ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]) params = Utils.__validate_and_extract_params arguments, valid_params body = nil params[:fields] = Utils.__listify(params[:fields]) if params[:fields] perform_request(method, path, params, body).body rescue Exception => e # NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false else raise(e) end end |
#get_source(arguments = {}) ⇒ Object
Return a specified document’s ‘_source`.
The response contains just the original document, as passed to Elasticsearch during indexing.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/elasticsearch/api/actions/get_source.rb', line 34 def get_source(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments[:type] ||= '_all' valid_params = [ :fields, :parent, :preference, :realtime, :refresh, :routing, :_source, :_source_include, :_source_exclude ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]), '_source' params = Utils.__validate_and_extract_params arguments, valid_params body = nil params[:fields] = Utils.__listify(params[:fields]) if params[:fields] perform_request(method, path, params, body).body rescue Exception => e # NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false else raise(e) end end |
#index(arguments = {}) ⇒ Object
Create or update a document.
The ‘index` API will either create a new document, or update an existing one, when a document `:id` is passed. When creating a document, an ID will be auto-generated, when it’s not passed as an argument.
You can specifically enforce the create operation by settint the ‘op_type` argument to `create`, or by using the #create method.
Optimistic concurrency control is performed, when the ‘version` argument is specified. By default, no version checks are performed.
By default, the document will be available for #get immediately, for #search only after an index refresh operation has been performed (either automatically or manually).
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/elasticsearch/api/actions/index.rb', line 53 def index(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] valid_params = [ :consistency, :op_type, :parent, :percolate, :refresh, :replication, :routing, :timeout, :timestamp, :ttl, :version, :version_type ] method = arguments[:id] ? 'PUT' : 'POST' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]) params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#info(arguments = {}) ⇒ Object
Return simple information about the cluster (name, version).
9 10 11 12 13 14 15 16 |
# File 'lib/elasticsearch/api/actions/info.rb', line 9 def info(arguments={}) method = 'GET' path = "" params = {} body = nil perform_request(method, path, params, body).body end |
#mget(arguments = {}) ⇒ Object
Return multiple documents from one or more indices in a single request.
Pass the request definition in the ‘:body` argument, either as an Array of `docs` specifications, or `ids`, when the `:index` and document `:type` are specified.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch/api/actions/mget.rb', line 46 def mget(arguments={}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] valid_params = [ :fields, :parent, :preference, :realtime, :refresh, :routing, :_source, :_source_include, :_source_exclude ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), '_mget' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] params[:fields] = Utils.__listify(params[:fields]) if params[:fields] perform_request(method, path, params, body).body end |
#mlt(arguments = {}) ⇒ Object
Return documents similar to the specified one.
Performs a ‘more_like_this` query with the specified document as the input.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/elasticsearch/api/actions/mlt.rb', line 46 def mlt(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] valid_params = [ :boost_terms, :max_doc_freq, :max_query_terms, :max_word_len, :min_doc_freq, :min_term_freq, :min_word_len, :mlt_fields, :percent_terms_to_match, :routing, :search_from, :search_indices, :search_query_hint, :search_scroll, :search_size, :search_source, :search_type, :search_types, :stop_words ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]), '_mlt' params = Utils.__validate_and_extract_params arguments, valid_params [:mlt_fields, :search_indices, :search_types, :stop_words].each do |name| params[name] = Utils.__listify(params[name]) if params[name] end body = arguments[:body] perform_request(method, path, params, body).body end |
#mpercolate(arguments = {}) ⇒ Object
Perform multiple percolate operations in a single request, similar to the #msearch API
Pass the percolate definitions as header-body pairs in the ‘:body` argument, as an Array of Hashes.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/elasticsearch/api/actions/mpercolate.rb', line 32 def mpercolate(arguments={}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] valid_params = [ :ignore_unavailable, :allow_no_indices, :expand_wildcards ] method = 'GET' path = "_mpercolate" params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] case when body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : MultiJson.dump(d) } payload << "" unless payload.empty? payload = payload.join("\n") else payload = body end perform_request(method, path, params, payload).body end |
#msearch(arguments = {}) ⇒ Object
Perform multiple search operations in a single request.
Pass the search definitions in the ‘:body` argument
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch/api/actions/msearch.rb', line 38 def msearch(arguments={}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] valid_params = [ :search_type ] method = 'GET' path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_msearch' ) params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] case when body.is_a?(Array) && body.any? { |d| d.has_key? :search } payload = body. inject([]) do |sum, item| = item data = .delete(:search) sum << sum << data sum end. map { |item| MultiJson.dump(item) } payload << "" unless payload.empty? payload = payload.join("\n") when body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : MultiJson.dump(d) } payload << "" unless payload.empty? payload = payload.join("\n") else payload = body end perform_request(method, path, params, payload).body end |
#mtermvectors(arguments = {}) ⇒ Object
Returns information and statistics about terms in the fields of multiple documents in a single request/response. The semantics are similar to the #mget API.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/elasticsearch/api/actions/mtermvectors.rb', line 35 def mtermvectors(arguments={}) valid_params = [ :ids, :term_statistics, :field_statistics, :fields, :offsets, :positions, :payloads, :preference, :routing, :parent ] ids = arguments.delete(:ids) method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), '_mtermvectors' params = Utils.__validate_and_extract_params arguments, valid_params if ids body = { :ids => ids } else body = arguments[:body] end perform_request(method, path, params, body).body end |
#percolate(arguments = {}) ⇒ Object
Return names of queries matching a document.
Percolator allows you to register queries and then evaluate a document against them: the IDs of matching queries are returned in the response.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/elasticsearch/api/actions/percolate.rb', line 76 def percolate(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] valid_params = [ :routing, :preference, :ignore_unavailable, :allow_no_indices, :expand_wildcards, :percolate_index, :percolate_type, :version, :version_type ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), arguments[:id], '_percolate' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#ping(arguments = {}) ⇒ Object
Returns true if the cluster returns a sucessfull HTTP response, false otherwise.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/elasticsearch/api/actions/ping.rb', line 13 def ping(arguments={}) method = 'HEAD' path = "" params = {} body = nil perform_request(method, path, params, body).status == 200 ? true : false rescue Exception => e if e.class.to_s =~ /NotFound/ || e. =~ /Not\s*Found|404/i false else raise e end end |
#scroll(arguments = {}) ⇒ Object
Efficiently iterate over a large result set.
When using ‘from` and `size` to return a large result sets, performance drops as you “paginate” in the set, and you can’t guarantee the consistency when the index is being updated at the same time.
“Scrolling” the results is frequently used with the ‘scan` search type.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/elasticsearch/api/actions/scroll.rb', line 29 def scroll(arguments={}) method = 'GET' path = "_search/scroll" valid_params = [ :scroll, :scroll_id ] params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#search(arguments = {}) ⇒ Hash
Return documents matching a query, as well as aggregations (facets), highlighted snippets, suggestions, etc.
The search API is used to query one or more indices either using simple [query string queries](www.elasticsearch.org/guide/reference/api/search/uri-request/) as the ‘:q` argument , or by passing the [full request definition](www.elasticsearch.org/guide/reference/api/search/request-body/) in the [Query DSL](www.elasticsearch.org/guide/reference/query-dsl/) as the `:body` argument.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/elasticsearch/api/actions/search.rb', line 106 def search(arguments={}) arguments[:index] = '_all' if ! arguments[:index] && arguments[:type] valid_params = [ :analyzer, :analyze_wildcard, :default_operator, :df, :explain, :fields, :from, :ignore_indices, :indices_boost, :lenient, :lowercase_expanded_terms, :preference, :q, :routing, :scroll, :search_type, :size, :sort, :source, :_source, :_source_include, :_source_exclude, :stats, :suggest_field, :suggest_mode, :suggest_size, :suggest_text, :timeout, :version ] method = 'GET' path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_search' ) params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] params[:fields] = Utils.__listify(params[:fields]) if params[:fields] perform_request(method, path, params, body).body end |
#suggest(arguments = {}) ⇒ Object
Return query terms suggestions based on provided text and configuration.
Pass the request definition in the ‘:body` argument.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/elasticsearch/api/actions/suggest.rb', line 29 def suggest(arguments={}) valid_params = [ :ignore_indices, :preference, :routing, :source ] method = '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 |
#termvector(arguments = {}) ⇒ Object
Return information and statistics about terms in the fields of a particular document
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/elasticsearch/api/actions/termvector.rb', line 47 def termvector(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] valid_params = [ :term_statistics, :field_statistics, :fields, :offsets, :positions, :payloads, :preference, :routing, :parent ] method = 'GET' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), arguments[:id], '_termvector' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end |
#update(arguments = {}) ⇒ Object
Update a document without sending the whole document in the request (“partial update”).
Send either a partial document (‘doc` ) which will be deeply merged into an existing document, or a `script`, which will update the document content, in the `:body` argument.
The partial update operation allows you to limit the amount of data you send over the wire and reduces the chance of failed updates due to conflict.
Specify the ‘:version` and `:retry_on_conflict` arguments to balance convenience and consistency.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/elasticsearch/api/actions/update.rb', line 64 def update(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] valid_params = [ :consistency, :fields, :lang, :parent, :percolate, :refresh, :replication, :retry_on_conflict, :routing, :script, :timeout, :timestamp, :ttl, :version, :version_type ] method = 'POST' path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]), '_update' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] params[:fields] = Utils.__listify(params[:fields]) if params[:fields] perform_request(method, path, params, body).body rescue Exception => e # NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false else raise(e) end end |