Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added description for indexing CouchDB. #4560

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading