flimzy commented on a change in pull request #418: Add search index
documentation
URL:
https://github.com/apache/couchdb-documentation/pull/418#discussion_r291741803
##########
File path: src/api/ddoc/views.rst
##########
@@ -315,6 +315,1128 @@ including the update sequence of the database from
which the view was
generated. The returned value can be compared this to the current update
sequence exposed in the database information (returned by :get:`/{db}`).
+Search
+======
+
+Search indexes enable you to query a database by using `Lucene Query Parser
Syntax
<http://lucene.apache.org/core/4_3_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Overview>`_.
A search index uses one, or multiple, fields from your documents. You can use
a search index to run queries, find documents based on the content they
contain, or work with groups, facets, or geographical searches.
+
+To create a search index, you add a JavaScript function to a design document
in the database. An index builds after processing one search request or after
the server detects a document update. The ``index`` function takes the
following parameters:
+
+1. Field name - The name of the field you want to use when you query the
index. If you set this parameter to ``default``, then this field is queried if
no field is specified in the query syntax.
+2. Data that you want to index, for example, ``doc.address.country``.
+3. (Optional) The third parameter includes the following fields: ``boost``,
``facet``, ``index``, and ``store``. These fields are described in more detail
later.
+
+By default, a search index response returns 25 rows. The number of rows that
is returned can be changed by using the ``limit`` parameter. However, a result
set from a search is limited to 200 rows. Each response includes a ``bookmark``
field. You can include the value of the ``bookmark`` field in later queries to
look through the responses.
+
+You can query the API by using one of the following methods: URI, CouchDB
Dashboard, curl, or a browser plug-in, such as Postman or RESTClient.
+
+*Example design document that defines a search index:*
+
+.. code-block:: json
+
+ {
+ "_id": "_design/search_example",
+ "indexes": {
+ "animals": {
+ "index": "function(doc){ ... }"
+ }
+ }
+ }
+
+Search index partitioning type
+------------------------------
+
+A search index will inherit the partitioning type from the
``options.partitioned``
+field of the design document that contains it.
+
+Index functions
+---------------
+
+Attempting to index by using a data field that does not exist fails. To avoid
this problem, use an appropriate :ref:`index_guard_clauses`.
+
+.. note::
+ Your indexing functions operate in a memory-constrained environment where
the
+ document itself forms a part of the memory that is used in that
environment.
+ Your code's stack and document must fit inside this memory. Documents are
limited
+ to a maximum size of 64 MB.
Review comment:
Does this 64mb limit apply only to search index functions? If so, this might
need to be clarified. If this limit is system-wide, does it need to be
(re-)mentioned here?
Assuming the limit only applies to search index functions, what is the
consequence of a > 64mb doc? I gather, from reading below, that it will simply
be omitted from the index, but it might be good to clarify.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services