Key operations on documents: indexing, search, deletion, etc
Key operations on documents: indexing, search, deletion, etc
(analyze conn text)
(analyze conn text opts)
Examples:
(require '[clojurewerkz.elastisch.rest.document :as doc])
(doc/analyze conn "foo bar baz")
(doc/analyze conn "foo bar baz" {:index "some-index-name"})
(doc/analyze conn "foo bar baz" {:analyzer "whitespace"})
(doc/analyze conn "foo bar baz" {:index "some-index-name" :field "some-field-name"})
Examples: ```clojure (require '[clojurewerkz.elastisch.rest.document :as doc]) (doc/analyze conn "foo bar baz") (doc/analyze conn "foo bar baz" {:index "some-index-name"}) (doc/analyze conn "foo bar baz" {:analyzer "whitespace"}) (doc/analyze conn "foo bar baz" {:index "some-index-name" :field "some-field-name"}) ```
(count conn index mapping-type)
(count conn index mapping-type query)
(count conn index mapping-type query opts)
Performs a count query over one or more indexes and types.
Multiple indexes and types can be specified using a seq of strings, otherwise specifying a string is enough.
Examples:
(require '[clojurewerkz.elastisch.rest.document :as doc])
(require '[clojurewerkz.elastisch.query :as q])
(doc/count conn "people" "person")
(doc/count conn "people" "person" (q/prefix {:username "appl"}))
Performs a count query over one or more indexes and types. Multiple indexes and types can be specified using a seq of strings, otherwise specifying a string is enough. ```clojure Examples: (require '[clojurewerkz.elastisch.rest.document :as doc]) (require '[clojurewerkz.elastisch.query :as q]) (doc/count conn "people" "person") (doc/count conn "people" "person" (q/prefix {:username "appl"})) ```
(create conn index mapping-type document)
(create conn index mapping-type document opts)
Adds document to the search index. 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 idExamples:
(require '[clojurewerkz.elastisch.rest.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"})
Adds document to the search index. 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: ```clojure (require '[clojurewerkz.elastisch.rest.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 conn index mapping-type id)
(delete conn index mapping-type id opts)
Deletes document from the index.
Deletes document from the index.
(delete-by-query conn index mapping-type query)
(delete-by-query conn index mapping-type query opts)
Performs a delete-by-query operation over one or more indexes and types.
Multiple indexes and types can be specified by passing in a seq of strings, otherwise specifying a string suffices.
Performs a delete-by-query operation over one or more indexes and types. Multiple indexes and types can be specified by passing in a seq of strings, otherwise specifying a string suffices.
(delete-by-query-across-all-indexes-and-types conn query)
(delete-by-query-across-all-indexes-and-types conn query opts)
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.
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 conn index query)
(delete-by-query-across-all-types conn index query opts)
Performs a delete-by-query operation over one or more indexes, across all mapping types.
Multiple indexes can be specified using a seq of strings, otherwise a single string suffices.
Performs a delete-by-query operation over one or more indexes, across all mapping types. Multiple indexes can be specified using a seq of strings, otherwise a single string suffices.
(get conn index mapping-type id)
(get conn index mapping-type id opts)
Fetches and returns a document by id or nil
if it does not exist.
Examples:
(require '[clojurewerkz.elastisch.rest.document :as doc])
(doc/get conn "people" "person" "1825c5432775b8d1a477acfae57e91ac8c767aed")
Fetches and returns a document by id or `nil` if it does not exist. Examples: ```clojure (require '[clojurewerkz.elastisch.rest.document :as doc]) (doc/get conn "people" "person" "1825c5432775b8d1a477acfae57e91ac8c767aed") ```
(more-like-this conn index mapping-type)
(more-like-this conn index mapping-type opts)
Performs a More Like This (MLT) query.
Performs a More Like This (MLT) query.
(multi-get conn query)
(multi-get conn index query)
(multi-get conn index mapping-type query)
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"}])
Multi get returns only documents that are found (exist). Queries can passed as a collection of maps with three keys: `:_index`, `:_type` and `:_id`: ```clojure (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: ```clojure (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: ```clojure (doc/multi-get conn index-name mapping-type [{:_id "1"} {:_id "2"}]) ```
Optional parameters that all query-based delete functions share
Optional parameters that all query-based delete functions share
(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.
Returns true if a document with the given id is present in the provided index with the given mapping type.
(put conn index mapping-type id document)
(put conn index mapping-type id document opts)
Creates or updates a document in the search index, using the provided document id
Creates or updates a document in the search index, using the provided document id
(replace conn index mapping-type id document)
Replaces document with given id with a new one
Replaces document with given id with a new one
(scroll conn scroll-id)
(scroll conn scroll-id opts)
Performs a scroll query, fetching the next page of results from a query given a scroll id
Performs a scroll query, fetching the next page of results from a query given a scroll id
(scroll-seq conn prev-resp)
(scroll-seq conn
prev-resp
{scroll-ttl :scroll :or {scroll-ttl "1m"} :keys [search_type]})
Returns a lazy sequence of all documents for a given scroll query
Returns a lazy sequence of all documents for a given scroll query
(search conn index mapping-type)
(search conn index mapping-type opts)
Performs a search query across one or more indexes and one or more mapping types.
Passing index name as "_all"
means searching across all indexes, multiple
indexes or types can be passed in as a seq of strings.
Examples:
(require '[clojurewerkz.elastisch.rest.document :as doc])
(require '[clojurewerkz.elastisch.query :as q])
(doc/search conn "people" "person" {:query (q/prefix {:username "appl"})})
Performs a search query across one or more indexes and one or more mapping types. Passing index name as `"_all"` means searching across all indexes, multiple indexes or types can be passed in as a seq of strings. Examples: ```clojure (require '[clojurewerkz.elastisch.rest.document :as doc]) (require '[clojurewerkz.elastisch.query :as q]) (doc/search conn "people" "person" {:query (q/prefix {:username "appl"})}) ```
(search-all-indexes-and-types conn)
(search-all-indexes-and-types conn opts)
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.
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 conn index)
(search-all-types conn index opts)
Performs a search query across one or more indexes and all mapping types.
Multiple indexes can be passed in as a seq of strings.
Performs a search query across one or more indexes and all mapping types. Multiple indexes can be passed in as a seq of strings.
(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
Updates an existing document in the search index with given partial document
(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 opts)
Updates a document using a script.
Examples:
(require '[clojurewerkz.elastisch.rest.document :as doc])
(doc/update-with-script conn "people" "person" "1825c5432775b8d1a477acfae57e91ac8c767aed"
"ctx._source.age = ctx._source.age += 1" {} {:lang "groovy"})
Updates a document using a script. Examples: ```clojure (require '[clojurewerkz.elastisch.rest.document :as doc]) (doc/update-with-script conn "people" "person" "1825c5432775b8d1a477acfae57e91ac8c767aed" "ctx._source.age = ctx._source.age += 1" {} {:lang "groovy"}) ```
(upsert conn index mapping-type id partial-doc)
(upsert conn index mapping-type id partial-doc opts)
Updates an existing document in the search index with given partial document, the provided document will be inserted if the document does not already exist
Updates an existing document in the search index with given partial document, the provided document will be inserted if the document does not already exist
(validate-query conn index query)
(validate-query conn index query opts)
Validates a query without actually executing it. Has the same API as search
but does not take the mapping-type
parameter.
Validates a query without actually executing it. Has the same API as [[search]] but does not take the `mapping-type` parameter.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close