zensols.dataset.elsearch

A client simple wrapper for an Elasticsearch wrapper. You probably want use the more client friendly zensols.dataset.db.

aggregation

(aggregation agg-query)

buckets

(buckets by-field)

Do an aggregation search and bucket by-field.

Return maps with keys:

  • :name value of name given by by-field
  • :count the count of the bucket

create-context

(create-context index-name mapping-type & {:keys [url mapping-type-defs settings], :or {url "http://localhost:9200", mapping-type-defs {:properties {mapping-type {}}}}})

Create a new context to be used with with-context.

Parameters

  • index-name the name of the Elasticsearch index
  • mapping-type map type name (see ES docs)

Keys

  • :url the URL to the DB (defaults to http://localhost:9200)
  • :mapping-type-defs metadata (see ES docs)

create-index

(create-index)

Create a new Elasticsearch index.

delete-document

(delete-document id)

delete-index

(delete-index)

Delete an Elasticsearch index.

delete-mapping

(delete-mapping)

Delete an Elasticsearch mapping.

describe

(describe)

Get the mapping (provide info) about the index.

document-by-id

(document-by-id id)

Return a document by its ID.

document-count

(document-count)

Return the total number of documents in the DB.

document-ids

(document-ids)(document-ids query)

Return document IDs only. The query default to match_all.

documents

(documents)

Return all documents as a lazy sequence.

exists?

(exists?)

put-document

(put-document doc)(put-document id doc)

Add a document to Elasticsearch.

recreate-index

(recreate-index)

Delete an then create Elasticsearch index.

search-literal

(search-literal query)

Return a lazy sequence of documents. Scanning is the underlying elastic search method here.

with-context

macro

(with-context exprs & forms)

Execute a body with the form (with-context [context ] …)