Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reference docs improvements for clojurewerkz.elastisch.rest.document

  • Loading branch information...
commit c6c653c30bbab233a13b1050f1cca50bcfc5f16b 1 parent cebebe3
Michael Klishin authored
Showing with 48 additions and 3 deletions.
  1. +48 −3 src/clojurewerkz/elastisch/rest/document.clj
View
51 src/clojurewerkz/elastisch/rest/document.clj
@@ -12,7 +12,31 @@
;;
(defn create
- "Adds document to the search index. Document id will be generated automatically"
+ "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:
+
+ (require '[clojurewerkz.elastisch.rest.document :as doc])
+
+ (doc/create \"people\" \"person\" {:first-name \"John\" :last-name \"Appleseed\" :age 28})
+
+ (doc/create \"people\" \"person\" {:first-name \"John\" :last-name \"Appleseed\" :age 28} :id \"1825c5432775b8d1a477acfae57e91ac8c767aed\")"
([index mapping-type document & {:as params}]
(rest/post (rest/mapping-type-url index mapping-type) :body document :query-params params)))
@@ -24,7 +48,13 @@
(rest/put (rest/record-url index mapping-type id) :body document :query-params params)))
(defn get
- "Fetches and returns a document by id or nil if it does not exist"
+ "Fetches and returns a document by id or nil if it does not exist.
+
+ Examples:
+
+ (require '[clojurewerkz.elastisch.rest.document :as doc])
+
+ (doc/get \"people\" \"person\" \"1825c5432775b8d1a477acfae57e91ac8c767aed\")"
[index mapping-type id & {:as params}]
(let [result (rest/get (rest/record-url index mapping-type id) :query-params params)]
(if (not-found? result)
@@ -83,7 +113,14 @@
(defn search
"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."
+ Passing index name as \"_all\" means searching across all indexes.
+
+ Examples:
+
+ (require '[clojurewerkz.elastisch.rest.document :as doc])
+ (require '[clojurewerkz.elastisch.query :as q])
+
+ (doc/search \"people\" \"person\" :query (q/prefix :username \"appl\"))"
[index mapping-type & {:as options}]
(let [qk [:search_type :scroll :routing :preference]
qp (select-keys options qk)
@@ -134,6 +171,14 @@
(defn count
"Performs a count query.
+ Examples:
+
+ (require '[clojurewerkz.elastisch.rest.document :as doc])
+ (require '[clojurewerkz.elastisch.query :as q])
+
+ (doc/count \"people\" \"person\")
+ (doc/count \"people\" \"person\" (q/prefix :username \"appl\"))
+
Related ElasticSearch documentation guide: http://www.elasticsearch.org/guide/reference/api/count.html"
([index mapping-type]
(rest/get (rest/count-url (join-names index) (join-names mapping-type))))
Please sign in to comment.
Something went wrong with that request. Please try again.