Permalink
Browse files

Good start on documenting current API

  • Loading branch information...
1 parent 3c2b0c1 commit 423c938430d04b0f5217a099eab365c6f8184bf0 @gsf gsf committed Mar 28, 2013
Showing with 54 additions and 1 deletion.
  1. +54 −1 README.md
View
@@ -20,7 +20,60 @@ es.query({query: {field: {field1: 'hai'}}}, function(err, results) {
API
===
-TBD
+Unless otherwise stated, all callbacks are called with `cb(err, res)`, with `res` being the parsed JSON response from elasticsearch.
+
+elasticsearch(opts)
+-------------------
+Shortcut for `elasticsearch.createClient(opts)`.
+
+elasticsearch.createClient(opts)
+--------------------------------
+Returns a new client object. Options:
+* `index`: The name of the index to attach to.
+
+We'll call the returned client `es`.
+
+es.status(opts, cb)
+-------------------
+Get the status of the index. *GET /index/_status*
+
+es.add(opts, doc, cb)
+---------------------
+Add a document to the index. *PUT /index/type/id* or *POST /index/type*
+
+Options:
+* `id`: Optional ID for the document. A UUID will be chosen by elasticsearch if no ID is specified.
+* `type`: Optional type for the document (default: `doc`).
+* `refresh`: Set this to true to refresh the index after add.
+
+es.delete(opts, cb)
+-------------------
+Delete a document or documents from the index. *DELETE /index/type/id*
+
+Options:
+* `id`: Optional ID for the document. All documents of this type will be deleted if no ID is specified.
+* `type`: Optional type for the document (default: `doc`).
+* `refresh`: Set this to true to refresh the index after delete.
+
+es.get(opts, cb)
+----------------
+Get a document from the index. *GET /index/type/id*
+
+Options:
+* `id`: ID for the document.
+* `type`: Optional type for the document (default: `doc`).
+
+es.query(opts, query, cb)
+-------------------------
+Query the index. *POST /index/_search*
+
+es.count(opts, query, cb)
+-------------------------
+Get the count of a query result set. *POST /index/_count*
+
+es.queryAll(opts, query, cb)
+----------------------------
+Query all indexes. *POST /_search*
Testing

0 comments on commit 423c938

Please sign in to comment.