You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2013/08/21 18:38:03 UTC
[36/50] git commit: updated
refs/heads/1781-reorganize-and-improve-docs to 360107b
Update Temporary views API reference.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/00e6c06f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/00e6c06f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/00e6c06f
Branch: refs/heads/1781-reorganize-and-improve-docs
Commit: 00e6c06f936e160b5caab42100ae6cf6382dfbdb
Parents: 12aed6f
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Aug 13 16:34:19 2013 +0400
Committer: Alexander Shorin <kx...@apache.org>
Committed: Wed Aug 21 20:29:40 2013 +0400
----------------------------------------------------------------------
share/doc/src/api/database/temp-views.rst | 86 ++++++++++++++------------
1 file changed, 46 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/00e6c06f/share/doc/src/api/database/temp-views.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/api/database/temp-views.rst b/share/doc/src/api/database/temp-views.rst
index 893a258..9bcecb5 100644
--- a/share/doc/src/api/database/temp-views.rst
+++ b/share/doc/src/api/database/temp-views.rst
@@ -12,57 +12,63 @@
.. _api/db/temp_view:
-.. _api/db/temp_view.post:
-``POST /db/_temp_view``
-=======================
+``/db/_temp_view``
+==================
-* **Method**: ``POST /db/_temp_view``
-* **Request**: JSON with the temporary view definition
-* **Response**: Temporary view result set
-* **Admin Privileges Required**: yes
+.. http:post:: /{db}/_temp_view
-Creates (and executes) a temporary view based on the view function
-supplied in the JSON request. For example:
+ Creates (and executes) a temporary view based on the view function
+ supplied in the JSON request.
-.. code-block:: http
+ The arguments also available to standard view requests also apply to
+ temporary views, but the execution of the view may take some time as it
+ relies on being executed at the time of the request. In addition to the
+ time taken, they are also computationally very expensive to produce. You
+ should use a defined view if you want to achieve the best performance.
- POST http://couchdb:5984/recipes/_temp_view
+ See :ref:`api/ddoc/view` for more info.
+
+ **Request**:
+
+ .. code-block:: http
+
+ POST /db/_temp_view?group=true HTTP/1.1
+ Accept: application/json
+ Content-Length: 92
Content-Type: application/json
+ Host: localhost:5984
{
- "map" : "function(doc) { if (doc.value > 9995) { emit(null, doc.value); } }"
+ "map": "function(doc) { if (doc.value) { emit(doc.value, null); } }",
+ "reduce": "_count"
}
-The resulting JSON response is the result from the execution of the
-temporary view:
+ **Response**:
-.. code-block:: javascript
+ .. code-block:: http
+
+ HTTP/1.1 200 OK
+ Cache-Control: must-revalidate
+ Content-Type: application/json
+ Date: Tue, 13 Aug 2013 12:28:12 GMT
+ ETag: "AU33B3N7S9K4SAZSFA048HVB4"
+ Server: CouchDB/1.4.0 (Erlang OTP/R16B)
+ Transfer-Encoding: chunked
{
- "total_rows" : 3,
- "rows" : [
- {
- "value" : 9998.41913029012,
- "id" : "05361cc6aa42033878acc1bacb1f39c2",
- "key" : null
- },
- {
- "value" : 9998.94149934853,
- "id" : "1f443f471e5929dd7b252417625ed170",
- "key" : null
- },
- {
- "value" : 9998.01511339154,
- "id" : "1f443f471e5929dd7b252417629c102b",
- "key" : null
- }
- ],
- "offset" : 0
+ "rows": [
+ {
+ "key": -10,
+ "value": 1
+ },
+ {
+ "key": 10,
+ "value": 2
+ },
+ {
+ "key": 15,
+ "value": 1
+ }
+ ]
}
-
-The arguments also available to standard view requests also apply to
-temporary views, but the execution of the view may take some time as it
-relies on being executed at the time of the request. In addition to the
-time taken, they are also computationally very expensive to produce. You
-should use a defined view if you want to achieve the best performance.