Skip to content

Commit

Permalink
Current API documented
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Farrell committed Apr 2, 2013
1 parent 423c938 commit 646ab25
Showing 1 changed file with 89 additions and 9 deletions.
98 changes: 89 additions & 9 deletions README.md
Expand Up @@ -28,18 +28,20 @@ Shortcut for `elasticsearch.createClient(opts)`.

elasticsearch.createClient(opts)
--------------------------------
Returns a new client object. Options:
* `index`: The name of the index to attach to.
Returns a new client object.

Options:
* `index`: The name of the index to act upon.

We'll call the returned client `es`.

es.status(opts, cb)
-------------------
Get the status of the index. *GET /index/_status*
Get the status of the index. Maps to *GET /index/_status*.

es.add(opts, doc, cb)
---------------------
Add a document to the index. *PUT /index/type/id* or *POST /index/type*
Add a document to the index. Maps to *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.
Expand All @@ -48,7 +50,7 @@ Options:

es.delete(opts, cb)
-------------------
Delete a document or documents from the index. *DELETE /index/type/id*
Delete a document or documents from the index. Maps to *DELETE /index/type/id*.

Options:
* `id`: Optional ID for the document. All documents of this type will be deleted if no ID is specified.
Expand All @@ -57,23 +59,101 @@ Options:

es.get(opts, cb)
----------------
Get a document from the index. *GET /index/type/id*
Get a document from the index. Maps to *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*
Query the index. Maps to *POST /index/_search*.

es.count(opts, query, cb)
-------------------------
Get the count of a query result set. *POST /index/_count*
Get the count of a query result set. Maps to *POST /index/_count*.

es.queryAll(opts, query, cb)
----------------------------
Query all indexes. *POST /_search*
Query all indexes. Maps to *POST /_search*.

es.putRiver(opts, river, cb)
----------------------------
Put a new or updated river. Maps to *PUT /_river/name/_meta*.

Options:
* `name`: Name for the river.

es.getRiver(opts, name, cb)
---------------------------
Get a river. Maps to *GET /_river/name/_meta*.

es.deleteRiver(opts, name, cb)
-------------------------------
Delete a river. Maps to *DELETE /_river/name/*.

es.putMapping(opts, config, cb)
-------------------------------
Put a new or updated mapping. Maps to *PUT /index/name/_mapping*.

`name` is defined by `config.name` and `mapping` by `config.mapping`.

es.getMapping(opts, type, cb)
-----------------------------
Get a mapping. Maps to *GET /index/type/_mapping*.

If type is an array its values will be joined.

es.deleteMapping(opts, config, cb)
----------------------------------
Delete a mapping. Maps to *DELETE /index/name/_mapping*.

`name` is defined by `config.name`.

new elasticsearch.Index(opts)
-----------------------------
Returns a new index object.

Options:
* `name`: The name of the index to act upon.

We'll call the returned index `index`.

index.status(opts, cb)
----------------------
Get the status of the index. Maps to *GET /index/_status*.

index.refresh(opts, cb)
-----------------------
Refresh the index. Maps to *POST /index/_refresh*.

index.create(opts, config, cb)
------------------------------
Create the index. Maps to *PUT /index/* or *POST /index/* depending on the existence of `config.mappings`.

index.delete(cb)
----------------
Delete the index. Maps to *DELETE /index*.

new elasticsearch.Cluster()
---------------------------
Returns a new cluster object.

We'll call the returned cluster `cluster`.

cluster.status(opts, cb)
------------------------
Get the status of the cluster. Maps to *GET /_status*.

cluster.deleteIndices(opts, cb)
-------------------------------
Delete all indices in this cluster. Maps to multiple calls to *DELETE /index/*.

cluster.health(opts, cb)
------------------------
Get health of the cluster. Maps to *GET _cluster/health*.

Options map to query parameters.


Testing
Expand Down

0 comments on commit 646ab25

Please sign in to comment.