Skip to content

Commit

Permalink
Added description for indexing CouchDB.
Browse files Browse the repository at this point in the history
Signed-off-by: Voroshilov Maksim <[email protected]>
  • Loading branch information
EnterpriseDeveloper authored and denyeart committed Nov 30, 2023
1 parent 946ae73 commit 4717bda
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/source/couchdb_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,34 @@ the CouchDB recommended practice.
}
If you want to add sorting to your indexing, add a sort type. Then you can query result at needed sort. Example below.

.. code:: json
{
"index":{
"fields":[
{
"owner":"desc"
},
{
"color":"desc"
},
{
"size":"desc"
}
] // Names of the fields to be queried and sorted for descending.
},
"ddoc":"index3Doc",
"name":"index3",
"type":"json"
}
.. tip:: Be aware if you want to have good performance in your query, put the most
restrictive field in the first place to limit the results the most.
In our case ``owner`` should be the first value in index ``fields``.
Because the ``owner`` carries a unique user identifier.

In general, you should model index fields to match the fields that will be used
in query filters and sorts. For more details on building an index in JSON
format refer to the `CouchDB documentation <http://docs.couchdb.org/en/stable/api/database/find.html#db-index>`__.
Expand Down

0 comments on commit 4717bda

Please sign in to comment.