Skip to content

Commit

Permalink
Update read-docs.adoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ujibang authored Jan 8, 2025
1 parent 31dbf2e commit d173db8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/mongodb-rest/read-docs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
GET /inventory?hint={'$natural':-1} HTTP/1.1

0 comments on commit d173db8

Please sign in to comment.