From d173db8fb125253d3f92c68d881091b1b5160ef1 Mon Sep 17 00:00:00 2001 From: Andrea Di Cesare Date: Wed, 8 Jan 2025 11:56:45 +0100 Subject: [PATCH] Update read-docs.adoc --- docs/mongodb-rest/read-docs.adoc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/mongodb-rest/read-docs.adoc b/docs/mongodb-rest/read-docs.adoc index bb38cf19..b80c47c5 100644 --- a/docs/mongodb-rest/read-docs.adoc +++ b/docs/mongodb-rest/read-docs.adoc @@ -319,7 +319,9 @@ Hint allows overriding MongoDB’s default index selection and query optimizatio This is done via the `hint` query parameter. -Specify the index by the index specification document, either using a json document or the compact string representation; specifying the index by name is not supported. +Specify the index using an index specification document, either as a JSON object or a compact string representation (e.g., `?hint=+key` or `?hint=-key`). Starting from version 8.3, you can also specify the index by name (e.g., `?hint=indexName`). + +For version 8.3: Use the compact string representation by prefixing the field name with `+` or `-`. Note that the `+` sign must be URL-encoded as `%2B`; otherwise, it will be interpreted as a space. If the `?hint` value does not start with `+` or `-`, it will be treated as an index name. Use `$natural` to force the query to perform a forwards collection scan. @@ -368,10 +370,9 @@ The following example returns all documents in the collection named **coll** usi [source,http] GET /inventory?hint={'item':1} HTTP/1.1 +==== Use the index on item and status fields using the compact string format -==== Use the compound index on age and timestamp fields using the compact string format - -The following example returns the documents using the compound index on the **item** and reverse **status** fields. +The following example returns the documents using the indexes **item** and reverse **status**. ++++ {% include code-header.html @@ -381,7 +382,7 @@ The following example returns the documents using the compound index on the **it ++++ [source,http] -GET /inventory?hint=item&hint=-status HTTP/1.1 +GET /inventory?hint=+item&hint=-status HTTP/1.1 ==== Perform a forwards collection scan @@ -410,4 +411,4 @@ The following example returns the documents using a reverse collection scan. ++++ [source,http] -GET /inventory?hint={'$natural':-1} HTTP/1.1 \ No newline at end of file +GET /inventory?hint={'$natural':-1} HTTP/1.1