|
| 1 | +.. Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 2 | +.. use this file except in compliance with the License. You may obtain a copy of |
| 3 | +.. the License at |
| 4 | +.. |
| 5 | +.. http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +.. |
| 7 | +.. Unless required by applicable law or agreed to in writing, software |
| 8 | +.. distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +.. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +.. License for the specific language governing permissions and limitations under |
| 11 | +.. the License. |
| 12 | +
|
| 13 | +.. _api/ddoc/search: |
| 14 | + |
| 15 | +============================================= |
| 16 | +``/db/_design/design-doc/_search/index-name`` |
| 17 | +============================================= |
| 18 | + |
| 19 | +.. versionadded:: 3.0 |
| 20 | + |
| 21 | +.. http:get:: /{db}/_design/{ddoc}/_search/{index} |
| 22 | + :synopsis: Returns results for the specified search index |
| 23 | + |
| 24 | + Executes a search request against the named index in the specified design document. |
| 25 | + |
| 26 | + :param db: Database name |
| 27 | + :param ddoc: Design document name |
| 28 | + :param index: Search index name |
| 29 | + |
| 30 | + :<header Accept: - :mimetype:`application/json` |
| 31 | + - :mimetype:`text/plain` |
| 32 | + |
| 33 | + :query string bookmark: A bookmark received from a previous search. This parameter |
| 34 | + enables paging through the results. If there are no more results after the |
| 35 | + bookmark, you get a response with an empty rows array and the same bookmark, |
| 36 | + confirming the end of the result list. |
| 37 | + :query json counts: An array of names of string fields for which counts |
| 38 | + are requested. The response contains counts for each unique value of this field |
| 39 | + name among the documents that match the search query. :ref:`Faceting |
| 40 | + <ddoc/search/faceting>` must be enabled for this parameter to function. |
| 41 | + :query json drilldown: This field can be used several times. Each use defines a pair |
| 42 | + with a field name and a value. The search matches only documents containing the |
| 43 | + value that was provided in the named field. It differs from using |
| 44 | + ``"fieldname:value"`` in the ``q`` parameter only in that the values are not |
| 45 | + analyzed. :ref:`Faceting <ddoc/search/faceting>` must be enabled for this |
| 46 | + parameter to function. |
| 47 | + :query string group_field: Field by which to group search matches. :query number |
| 48 | + group_limit: Maximum group count. This field can be used only if ``group_field`` |
| 49 | + is specified. |
| 50 | + :query json group_sort: This field defines the order of the groups in a search that |
| 51 | + uses ``group_field``. The default sort order is relevance. |
| 52 | + :query json highlight_fields: Specifies which fields to highlight. If specified, the |
| 53 | + result object contains a ``highlights`` field with an entry for each specified |
| 54 | + field. |
| 55 | + :query string highlight_pre_tag: A string that is inserted before the highlighted |
| 56 | + word in the highlights output. |
| 57 | + :query string highlight_post_tag: A string that is inserted after the highlighted |
| 58 | + word in the highlights output. |
| 59 | + :query number highlight_number: Number of fragments that are returned in highlights. |
| 60 | + If the search term occurs less often than the number of fragments that are |
| 61 | + specified, longer fragments are returned. |
| 62 | + :query number highlight_size: Number of characters in each fragment for highlights. |
| 63 | + :query boolean include_docs: Include the full content of the documents in the |
| 64 | + response. |
| 65 | + :query json include_fields: A JSON array of field names to include in search |
| 66 | + results. Any fields that are included must be indexed with the store:true option. |
| 67 | + :query number limit: Limit the number of the returned documents to the specified |
| 68 | + number. For a grouped search, this parameter limits the number of documents per |
| 69 | + group. |
| 70 | + :query string q: Alias for ``query``. |
| 71 | + :query string query: Required. The Lucene query string. |
| 72 | + :query json ranges: This field defines ranges for faceted, numeric search fields. The |
| 73 | + value is a JSON object where the fields names are faceted numeric search fields, |
| 74 | + and the values of the fields are JSON objects. The field names of the JSON objects |
| 75 | + are names for ranges. The values are strings that describe the range, for example |
| 76 | + "[0 TO 10]". |
| 77 | + :query json sort: Specifies the sort order of the results. In a grouped search (when |
| 78 | + ``group_field`` is used), this parameter specifies the sort order within a group. |
| 79 | + The default sort order is relevance. A JSON string of the form |
| 80 | + ``"fieldname<type>"`` or ``-fieldname<type>`` for descending order, where |
| 81 | + fieldname is the name of a string or number field, and ``type`` is either a |
| 82 | + number, a string, or a JSON array of strings. The ``type`` part is optional, and |
| 83 | + defaults to number. Some examples are ``"foo"``, ``"-foo"``, ``"bar<string>"``, |
| 84 | + ``"-foo<number>"`` and [``"-foo<number>"``, ``"bar<string>"``]. String fields that |
| 85 | + are used for sorting must not be analyzed fields. Fields that are used for sorting |
| 86 | + must be indexed by the same indexer that is used for the search query. |
| 87 | + :query string stale: Set to ``ok`` to allow the use of an out-of-date index. |
| 88 | + |
| 89 | + :>header Content-Type: - :mimetype:`application/json` |
| 90 | + - :mimetype:`text/plain; charset=utf-8` |
| 91 | + :>header ETag: Response signature |
| 92 | + :>header Transfer-Encoding: ``chunked`` |
| 93 | + |
| 94 | + :>json array rows: Array of view row objects. By default the information |
| 95 | + returned contains only the document ID and revision. |
| 96 | + :>json number total_rows: Number of documents in the database/view. |
| 97 | + :>json string bookmark: Opaque identifier to enable pagination. |
| 98 | + |
| 99 | + :code 200: Request completed successfully |
| 100 | + :code 400: Invalid request |
| 101 | + :code 401: Read permission required |
| 102 | + :code 404: Specified database, design document or view is missed |
| 103 | + |
| 104 | +.. note:: |
| 105 | + You must enable :ref:`faceting <ddoc/search/faceting>` before you can use the |
| 106 | + ``counts``, ``drilldown``, and ``ranges`` parameters. |
| 107 | + |
| 108 | +.. note:: |
| 109 | + Faceting and grouping are not supported on partitioned searches, so the following |
| 110 | + query parameters should not be used on those requests: ``counts``, ``drilldown``, |
| 111 | + ``ranges``, and ``group_field``, ``group_limit``, group_sort``. |
| 112 | + |
| 113 | +.. note:: |
| 114 | + Do not combine the ``bookmark`` and ``stale`` options. These options constrain the |
| 115 | + choice of shard replicas to use for the response. When used together, the options |
| 116 | + might cause problems when contact is attempted with replicas that are slow or not |
| 117 | + available. |
| 118 | + |
| 119 | +.. warning:: |
| 120 | + Search requests will fail unless the CouchDB server is connected to a functioning |
| 121 | + Clouseau instance. |
| 122 | + |
| 123 | +.. seealso:: |
| 124 | + For more information about how search works, see the |
| 125 | + :ref:`Search User Guide<ddoc/search>`. |
| 126 | + |
| 127 | +================================================== |
| 128 | +``/db/_design/design-doc/_search_info/index-name`` |
| 129 | +================================================== |
| 130 | + |
| 131 | +.. versionadded:: 3.0 |
| 132 | + |
| 133 | +.. http:get:: /{db}/_design/{ddoc}/_search_info/{index} |
| 134 | + :synopsis: Returns metadata for the specified search index |
| 135 | + |
| 136 | + :param db: Database name |
| 137 | + :param ddoc: Design document name |
| 138 | + :param index: Search index name |
| 139 | + :code 200: Request completed successfully |
| 140 | + :code 400: Request body is wrong (malformed or missing one of the mandatory fields) |
| 141 | + :code 500: A server error (or other kind of error) occurred |
| 142 | + |
| 143 | +**Request**: |
| 144 | + |
| 145 | +.. code-block:: http |
| 146 | +
|
| 147 | + GET /recipes/_design/cookbook/_search_info/ingredients HTTP/1.1 |
| 148 | + Accept: application/json |
| 149 | + Host: localhost:5984 |
| 150 | +
|
| 151 | +**Response**: |
| 152 | + |
| 153 | +.. code-block:: javascript |
| 154 | +
|
| 155 | + { |
| 156 | + "name": "_design/cookbook/ingredients", |
| 157 | + "search_index": { |
| 158 | + "pending_seq": 7125496, |
| 159 | + "doc_del_count": 129180, |
| 160 | + "doc_count": 1066173, |
| 161 | + "disk_size": 728305827, |
| 162 | + "committed_seq": 7125496 |
| 163 | + } |
| 164 | + } |
0 commit comments