couchdb icon indicating copy to clipboard operation
couchdb copied to clipboard

Couchdb 3.3 Documentation on Query parameters for Search plugin, remove quotes

Open bpluly opened this issue 5 years ago • 2 comments

The documentation at https://docs.couchdb.org/en/master/ddocs/search.html#queries includes examples for queries but shows the query= string wrapped in quotes. The parameter is not quoted. If you use it in curl as documented it will hang on the query.

Developers no doubt figure this out but it can be avoided. Existing documentation examples.

GET /$DATABASE/_partition/$PARTITION_KEY/_design/$DDOC/_search/$INDEX_NAME?include_docs=true&query="*:*"&limit=1 HTTP/1.1
Content-Type: application/json

Example of using HTTP to query a global index:

GET /$DATABASE/_design/$DDOC/_search/$INDEX_NAME?include_docs=true&query="*:*"&limit=1 HTTP/1.1
Content-Type: application/json

Example of using the command line to query a partitioned index:

curl https://$HOST:5984/$DATABASE/_partition/$PARTITION_KEY/_design/$DDOC/
_search/$INDEX_NAME?include_docs=true\&query="*:*"\&limit=1 \

Example of using the command line to query a global index:

curl https://$HOST:5984/$DATABASE/_design/$DDOC/_search/$INDEX_NAME?
include_docs=true\&query="*:*"\&limit=1 \

The example of *:* is also misleading. It will return the default for the index which is likely to be all _id's in the database. But if an index is specified the value cannot start with either '?' or '*'. Perhaps something like:

GET /$DATABASE/_partition/$PARTITION_KEY/_design/$DDOC/_search/$INDEX_NAME?include_docs=true&query=$index:$searchString&limit=1 HTTP/1.1
Content-Type: application/json

Example of using HTTP to query a global index:

GET /$DATABASE/_design/$DDOC/_search/$INDEX_NAME?include_docs=true&query=$index:$searchString&limit=1 HTTP/1.1
Content-Type: application/json

Example of using the command line to query a partitioned index:

curl https://$HOST:5984/$DATABASE/_partition/$PARTITION_KEY/_design/$DDOC/
_search/$INDEX_NAME?include_docs=true\&query=$index:$searchString\&limit=1 \

Example of using the command line to query a global index:

curl https://$HOST:5984/$DATABASE/_design/$DDOC/_search/$INDEX_NAME?
include_docs=true\&query=$index:$searchString\&limit=1 \

NOTE
Using *:* for the index and search string will use the default rule in the search index document. If this is the normal index('default', doc._id); then all documents in the database will be returned. In normal circumstances the search string cannot start with a wildcard (?,*).

This should save some needless scratching of heads.

bpluly avatar Aug 28 '20 14:08 bpluly

Hi, I would like to work on this documentation update.

I will update the search query examples by removing the incorrect quotes, replacing the misleading : example with a correct one, and adjusting the curl/HTTP examples accordingly. I’ll also add a short note explaining when the default index rule applies.

I have reviewed the documentation file and will update the examples under: src/docs/ddocs/search.rst

Please let me know if this approach looks good. Thanks!

piyahub avatar Dec 11 '25 04:12 piyahub

Hi @piyahub,

if there is something missing in the docs or could be improved, please go ahead and open a PR. We will discuss the changes there. You can find some contribution tips in our guide and I would like to draw particular attention to our prohibition of artificial intelligence.

rnewson avatar Dec 11 '25 10:12 rnewson