clojurewerkz.elastisch.native.document

async-create

(async-create conn index mapping-type document)(async-create conn index mapping-type document & args)
Adds document to the search index and returns a future without waiting
for the response. Takes exactly the same arguments as create.

async-get

(async-get conn index mapping-type id)(async-get conn index mapping-type id & args)
Fetches and returns a document by id or nil if it does not exist.
Returns a future without waiting.

async-put

(async-put conn index mapping-type id document)(async-put conn index mapping-type id document & args)
Creates or updates a document in the search index using the provided document id
and returns a future without waiting for the response. Takes exactly the same arguments as put.

count

(count conn index mapping-type)(count conn index mapping-type query)(count conn index mapping-type query & args)
Performs a count query.

Examples:

(require '[clojurewerkz.elastisch.native.document :as doc])
(require '[clojurewerkz.elastisch.query :as q])

(doc/count conn "people" "person")
(doc/count conn "people" "person" (q/prefix :username "appl"))

create

(create conn index mapping-type document)(create conn index mapping-type document & args)
Adds document to the search index and waits for the response.
If not given as an option, document id will be generated automatically.

Options:

  * :id (string): unique document id. If not provided, it will be generated by ElasticSearch
  * :timestamp (string): document timestamp either as millis since the epoch,
                                       or, in the configured date format
  * :ttl (long): document TTL in milliseconds. Must be > 0
  * :refresh (boolean, default: false): should a refresh be executed post this index operation?
  * :version (long): document version
  * :version-type (string, default: "internal"): "internal" or "external"
  * :content-type (string): document content type
  * :routing (string): controls the shard routing of the request. Using this value to hash the shard
                       and not the id
  * :percolate (string): the percolate query to use to reduce the percolated queries that are going to run against this doc.
                        Can be set to "*" which means "all queries"
  * :parent (string): parent document id

Examples:

(require '[clojurewerkz.elastisch.native.document :as doc])

(doc/create conn "people" "person" {:first-name "John" :last-name "Appleseed" :age 28})

(doc/create conn "people" "person" {:first-name "John" :last-name "Appleseed" :age 28} :id "1825c5432775b8d1a477acfae57e91ac8c767aed")

delete

(delete conn index mapping-type id)(delete conn index mapping-type id & args)
Deletes document from the index.

Examples:

(require '[clojurewerkz.elastisch.native.document :as doc])

(doc/delete conn "people" "person" "1825c5432775b8d1a477acfae57e91ac8c767aed")

delete-by-query

(delete-by-query conn index mapping-type query)(delete-by-query conn index mapping-type query & args)
Performs a delete-by-query operation.

Examples:

(require '[clojurewerkz.elastisch.native.document :as doc])
(require '[clojurewerkz.elastisch.query :as q])

(doc/delete-by-query conn "people" "person" (q/term :username "appleseed"))

delete-by-query-across-all-indexes-and-types

(delete-by-query-across-all-indexes-and-types conn query)(delete-by-query-across-all-indexes-and-types conn query & args)
Performs a delete-by-query operation across all indexes and mapping types.
This may put very high load on your ElasticSearch cluster so use this function with care.

delete-by-query-across-all-types

(delete-by-query-across-all-types conn index query)(delete-by-query-across-all-types conn index query & args)
Performs a delete-by-query operation across all mapping types.

get

(get conn index mapping-type id)(get conn index mapping-type id & args)
Fetches and returns a document by id or nil if it does not exist.
Waits for response.

Examples:

(require '[clojurewerkz.elastisch.native.document :as doc])

(doc/get conn "people" "person" "1825c5432775b8d1a477acfae57e91ac8c767aed")

more-like-this

(more-like-this conn index mapping-type id & args)
Performs a More Like This (MLT) query.

multi-get

(multi-get conn queries)(multi-get conn index queries)(multi-get conn index mapping-type queries)
Multi get returns only documents that are found (exist).

Queries can passed as a collection of maps with three keys: :_index,
:_type and :_id:

(doc/multi-get conn [{:_index index-name :_type mapping-type :_id "1"}
                     {:_index index-name :_type mapping-type :_id "2"}])


2-argument version accepts an index name that eliminates the need to include
:_index in every query map:

(doc/multi-get conn index-name [{:_type mapping-type :_id "1"}
                                {:_type mapping-type :_id "2"}])

3-argument version also accepts a mapping type that eliminates the need to include
:_type in every query map:

(doc/multi-get conn index-name mapping-type [{:_id "1"}
                                             {:_id "2"}])

present?

(present? conn index mapping-type id)
Returns true if a document with the given id is present in the provided index
with the given mapping type.

put

(put conn index mapping-type id document)(put conn index mapping-type id document & args)
Creates or updates a document in the search index using the provided document id
and waits for the response.

replace

(replace conn index mapping-type id document)
Replaces document with given id with a new one

scroll

(scroll conn scroll-id & args)
Performs a scroll query, fetching the next page of results from a
query given a scroll id

scroll-seq

(scroll-seq conn prev-resp {:keys [search_type]})(scroll-seq conn prev-resp)
Returns a lazy sequence of all documents for a given scroll query

search-all-indexes-and-types

(search-all-indexes-and-types conn & args)
Performs a search query across all indexes and all mapping types. This may put very high load on your
ElasticSearch cluster so use this function with care.

search-all-types

(search-all-types conn index & args)
Performs a search query across one or more indexes and all mapping types.

suggest

(suggest conn indices suggest-type term opts)
Suggests similar looking terms based on a provided text by using a suggester.

Usage:

(suggest es-conn "locations" :completion "Stockh" {:field "suggest" :size 5})

update-with-partial-doc

(update-with-partial-doc conn index mapping-type id partial-doc)(update-with-partial-doc conn index mapping-type id partial-doc opts)
Updates an existing document in the search index with given partial document

update-with-script

(update-with-script conn index mapping-type id script)(update-with-script conn index mapping-type id script params)(update-with-script conn index mapping-type id script params & args)
Updates a document using a script

upsert

(upsert conn index mapping-type id doc)(upsert conn index mapping-type id doc opts)
Updates or creates a document using provided data