View Source ElasticsearchEx.Api.Document.Single (Elasticsearch_ex v0.4.0)
Provides the APIs for the single document operations.
Summary
Types
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
Represents the source of a document
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
It describes the query sent to update the document.
Functions
Adds a JSON document to the specified data stream or index and makes it searchable.
Removes a JSON document from the specified index.
Checks if the specified JSON document from an index exists.
Retrieves the specified JSON document from an index.
Retrieves the specified JSON source from an index.
Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.
Checks if the specified JSON source from an index exists.
Updates a document using the specified script.
Types
The possible individual options accepted by the search
function.
@type create_opts() :: [create_opt() | {:http_opts, keyword()} | {atom(), any()}]
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
@type delete_opts() :: [delete_opt() | {:http_opts, keyword()} | {atom(), any()}]
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
@type document_exists_opts() :: [ document_exists_opt() | {:http_opts, keyword()} | {atom(), any()} ]
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
@type get_document_opts() :: [ get_document_opt() | {:http_opts, keyword()} | {atom(), any()} ]
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
@type get_source_opts() :: [ get_source_opt() | {:http_opts, keyword()} | {atom(), any()} ]
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
The possible options accepted by the search
function.
@type source() :: map()
Represents the source of a document
The possible individual options accepted by the search
function.
@type source_exists_opts() :: [ source_exists_opt() | {:http_opts, keyword()} | {atom(), any()} ]
The possible options accepted by the search
function.
The possible individual options accepted by the search
function.
@type update_opts() :: [update_opt() | {:http_opts, keyword()} | {atom(), any()}]
The possible options accepted by the search
function.
@type update_query() :: map()
It describes the query sent to update the document.
Functions
@spec create(source(), create_opts()) :: ElasticsearchEx.Client.response()
Adds a JSON document to the specified data stream or index and makes it searchable.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Request body
Refer to the official documentation for a detailed list of the body values.
Examples
iex> ElasticsearchEx.Api.Document.Single.create(
...> %{
...> "@timestamp": "2099-11-15T13:12:00",
...> message: "GET /search HTTP/1.1 200 1070000",
...> user: %{id: "kimchy"}
...> },
...> index: "my-index-000001",
...> id: "W0tpsmIBdwcYyG50zbta"
...> )
{:ok,
%{
"_id" => "W0tpsmIBdwcYyG50zbta",
"_index" => "my-index-000001",
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 2, "total" => 2},
"_version" => 1,
"result" => "created"
}}
@spec delete(delete_opts()) :: ElasticsearchEx.Client.response()
Removes a JSON document from the specified index.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Examples
iex> ElasticsearchEx.Api.Document.Single.delete(index: "my-index-000001", id: "0")
{:ok,
%{
"_id" => "0",
"_index" => "my-index-000001",
"_primary_term" => 3,
"_seq_no" => 6,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_version" => 2,
"result" => "deleted"
}}
iex> ElasticsearchEx.Api.Document.Single.delete(index: "my-index-000001", id: "1")
{:error,
%ElasticsearchEx.Error{
reason: "Document with ID: `1` not found",
root_cause: nil,
status: 404,
type: "not_found",
...
}}
@spec document_exists?(document_exists_opts()) :: boolean()
Checks if the specified JSON document from an index exists.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Examples
iex> ElasticsearchEx.Api.Document.Single.document_exists?(index: "my-index-000001", id: "0")
true
@spec get_document(get_document_opts()) :: ElasticsearchEx.Client.response()
Retrieves the specified JSON document from an index.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Examples
iex> ElasticsearchEx.Api.Document.Single.get_document(index: "my-index-000001", id: "0")
{:ok,
%{
"_id" => "0",
"_index" => "my-index-000001",
"_primary_term" => 1,
"_seq_no" => 0,
"_source" => %{
"@timestamp" => "2099-11-15T14:12:12",
"http" => %{
"request" => %{"method" => "get"},
"response" => %{"bytes" => 1070000, "status_code" => 200},
"version" => "1.1"
},
"message" => "GET /search HTTP/1.1 200 1070000",
"source" => %{"ip" => "127.0.0.1"},
"user" => %{"id" => "kimchy"}
},
"_version" => 1,
"found" => true
}}
@spec get_source(get_source_opts()) :: ElasticsearchEx.Client.response()
Retrieves the specified JSON source from an index.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Examples
iex> ElasticsearchEx.Api.Document.Single.get_source(index: "my-index-000001", id: "0")
{:ok,
%{
"@timestamp" => "2099-11-15T14:12:12",
"http" => %{
"request" => %{"method" => "get"},
"response" => %{"bytes" => 1_070_000, "status_code" => 200},
"version" => "1.1"
},
"message" => "GET /search HTTP/1.1 200 1070000",
"source" => %{"ip" => "127.0.0.1"},
"user" => %{"id" => "kimchy"}
}}
@spec index(source(), index_opts()) :: ElasticsearchEx.Client.response()
Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Request body
Refer to the official documentation for a detailed list of the body values.
Examples
Without a specific document ID:
iex> ElasticsearchEx.Api.Document.Single.index(
...> %{
...> "@timestamp": "2099-11-15T13:12:00",
...> message: "GET /search HTTP/1.1 200 1070000",
...> user: %{id: "kimchy"}
...> },
...> index: "my-index-000001"
...> )
{:ok,
%{
"_id" => "W0tpsmIBdwcYyG50zbta",
"_index" => "my-index-000001",
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 2, "total" => 2},
"_version" => 1,
"result" => "created"
}}
With a specific document ID:
iex> ElasticsearchEx.Api.Document.Single.index(
...> %{
...> "@timestamp": "2099-11-15T13:12:00",
...> message: "GET /search HTTP/1.1 200 1070000",
...> user: %{id: "kimchy"}
...> },
...> index: "my-index-000001",
...> id: "W0tpsmIBdwcYyG50zbta"
...> )
{:ok,
%{
"_id" => "W0tpsmIBdwcYyG50zbta",
"_index" => "my-index-000001",
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 2, "total" => 2},
"_version" => 1,
"result" => "created"
}}
@spec source_exists?(source_exists_opts()) :: boolean()
Checks if the specified JSON source from an index exists.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Examples
iex> ElasticsearchEx.Api.Document.Single.source_exists?(index: "my-index-000001", id: "0")
true
@spec update(update_query(), delete_opts()) :: ElasticsearchEx.Client.response()
Updates a document using the specified script.
Query parameters
Refer to the official documentation for a detailed list of the parameters.
Request body
Refer to the official documentation for a detailed list of the body values.