You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2016/09/07 12:40:52 UTC

documentation commit: updated refs/heads/master to b986a3b

Repository: couchdb-documentation
Updated Branches:
  refs/heads/master 57741f6b4 -> b986a3b36


document sending multiple queries to views

Fixes COUCHDB-3122


Project: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/commit/b986a3b3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/tree/b986a3b3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/diff/b986a3b3

Branch: refs/heads/master
Commit: b986a3b3614d291f92439214f97dd3bdf31d4728
Parents: 57741f6
Author: Will Holley <wi...@gmail.com>
Authored: Wed Sep 7 13:19:32 2016 +0100
Committer: Will Holley <wi...@gmail.com>
Committed: Wed Sep 7 13:19:32 2016 +0100

----------------------------------------------------------------------
 src/api/ddoc/views.rst | 133 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-documentation/blob/b986a3b3/src/api/ddoc/views.rst
----------------------------------------------------------------------
diff --git a/src/api/ddoc/views.rst b/src/api/ddoc/views.rst
index 6daaeac..be71e03 100644
--- a/src/api/ddoc/views.rst
+++ b/src/api/ddoc/views.rst
@@ -770,3 +770,136 @@ To omit some records you may use ``skip`` query parameter:
     Using ``limit`` and ``skip`` parameters is not recommended for results
     pagination. Read :ref:`pagination recipe <views/pagination>` why it's so
     and how to make it better.
+
+.. _api/ddoc/view/multiple_queries:
+
+Sending multiple queries to a view
+==================================
+
+.. versionadded:: 2.0
+
+.. http:post:: /{db}/_design/{ddoc}/_view/{view}
+    :synopsis: Returns results for the specified queries
+
+    Executes multiple specified view queries against the view function
+    from the specified design document.
+
+    :param db: Database name
+    :param ddoc: Design document name
+    :param view: View function name
+
+    :<header Content-Type: - :mimetype:`application/json`
+    :<header Accept: - :mimetype:`application/json`
+                     - :mimetype:`text/plain`
+
+    :query json queries: An array of query objects with fields for the
+        parameters of each individual view query to be executed. The field names
+        and their meaning are the same as the query parameters of a
+        regular :ref:`view request <api/ddoc/view>`.
+
+    :>header Content-Type: - :mimetype:`application/json`
+                           - :mimetype:`text/plain; charset=utf-8`
+    :>header ETag: Response signature
+    :>header Transfer-Encoding: ``chunked``
+
+    :>json array results: An array of result objects - one for each query. Each
+        result object contains the same fields as the response to a regular
+        :ref:`view request <api/ddoc/view>`.
+
+    :code 200: Request completed successfully
+    :code 400: Invalid request
+    :code 401: Read permission required
+    :code 404: Specified database, design document or view is missed
+    :code 500: View function execution error
+
+**Request**:
+
+.. code-block:: http
+
+    POST /recipes/_design/recipes/_view/by_title HTTP/1.1
+    Content-Type: application/json
+    Accept: application/json
+    Host: localhost:5984
+
+    {
+        "queries": [
+            {
+                "keys": [
+                    "meatballs",
+                    "spaghetti"
+                ]
+            },
+            {
+                "limit": 3,
+                "skip": 2
+            }
+        ]
+    }
+
+**Response**:
+
+.. code-block:: http
+
+    HTTP/1.1 200 OK
+    Cache-Control: must-revalidate
+    Content-Type: application/json
+    Date: Wed, 07 Sep 2016 11:17:07 GMT
+    ETag: "1H8RGBCK3ABY6ACDM7ZSC30QK"
+    Server: CouchDB (Erlang/OTP)
+    Transfer-Encoding: chunked
+
+    {
+        "results" : [
+            {
+                "offset": 0,
+                "rows": [
+                    {
+                        "id": "SpaghettiWithMeatballs",
+                        "key": "meatballs",
+                        "value": 1
+                    },
+                    {
+                        "id": "SpaghettiWithMeatballs",
+                        "key": "spaghetti",
+                        "value": 1
+                    },
+                    {
+                        "id": "SpaghettiWithMeatballs",
+                        "key": "tomato sauce",
+                        "value": 1
+                    }
+                ],
+                "total_rows": 3
+            },
+            {
+                "offset" : 2,
+                "rows" : [
+                    {
+                        "id" : "Adukiandorangecasserole-microwave",
+                        "key" : "Aduki and orange casserole - microwave",
+                        "value" : [
+                            null,
+                            "Aduki and orange casserole - microwave"
+                        ]
+                    },
+                    {
+                        "id" : "Aioli-garlicmayonnaise",
+                        "key" : "Aioli - garlic mayonnaise",
+                        "value" : [
+                            null,
+                            "Aioli - garlic mayonnaise"
+                        ]
+                    },
+                    {
+                        "id" : "Alabamapeanutchicken",
+                        "key" : "Alabama peanut chicken",
+                        "value" : [
+                            null,
+                            "Alabama peanut chicken"
+                        ]
+                    }
+                ],
+                "total_rows" : 2667
+            }
+        ]
+    }