Module: Elastic::AppSearch::Client::Documents
- Included in:
- Elastic::AppSearch::Client
- Defined in:
- lib/elastic/app-search/client/documents.rb
Instance Method Summary collapse
-
#destroy_documents(engine_name, ids) ⇒ Array<Hash>
Destroy a batch of documents given a list of IDs.
-
#get_documents(engine_name, ids) ⇒ Hash
Retrieve Documents from the API by IDs for the App Search API.
-
#index_document(engine_name, document) ⇒ Hash
Index a document using the App Search API.
-
#index_documents(engine_name, documents) ⇒ Array<Hash>
Index a batch of documents using the App Search API.
-
#list_documents(engine_name, options = {}) ⇒ Array<Hash>
Retrieve all Documents from the API for the App Search API.
-
#update_documents(engine_name, documents) ⇒ Array<Hash>
Update a batch of documents using the App Search API.
Instance Method Details
#destroy_documents(engine_name, ids) ⇒ Array<Hash>
Destroy a batch of documents given a list of IDs
79 80 81 |
# File 'lib/elastic/app-search/client/documents.rb', line 79 def destroy_documents(engine_name, ids) delete("engines/#{engine_name}/documents", ids) end |
#get_documents(engine_name, ids) ⇒ Hash
Retrieve Documents from the API by IDs for the App Search API
26 27 28 |
# File 'lib/elastic/app-search/client/documents.rb', line 26 def get_documents(engine_name, ids) get("engines/#{engine_name}/documents", ids) end |
#index_document(engine_name, document) ⇒ Hash
Index a document using the App Search API.
39 40 41 42 43 44 |
# File 'lib/elastic/app-search/client/documents.rb', line 39 def index_document(engine_name, document) response = index_documents(engine_name, [document]) errors = response.first['errors'] raise InvalidDocument.new(errors.join('; ')) if errors.any? response.first.tap { |h| h.delete('errors') } end |
#index_documents(engine_name, documents) ⇒ Array<Hash>
Index a batch of documents using the App Search API.
55 56 57 58 |
# File 'lib/elastic/app-search/client/documents.rb', line 55 def index_documents(engine_name, documents) documents.map! { |document| normalize_document(document) } post("engines/#{engine_name}/documents", documents) end |
#list_documents(engine_name, options = {}) ⇒ Array<Hash>
Retrieve all Documents from the API for the App Search API
15 16 17 18 |
# File 'lib/elastic/app-search/client/documents.rb', line 15 def list_documents(engine_name, = {}) params = Utils.symbolize_keys() request(:get, "engines/#{engine_name}/documents/list", params) end |
#update_documents(engine_name, documents) ⇒ Array<Hash>
Update a batch of documents using the App Search API.
69 70 71 72 |
# File 'lib/elastic/app-search/client/documents.rb', line 69 def update_documents(engine_name, documents) documents.map! { |document| normalize_document(document) } patch("engines/#{engine_name}/documents", documents) end |