0

I am using CosmosDB MongoDB API for store and retrieval of documents in the collections.

I am trying to use the sort collection.find({}).sort({field1: 1} and seeing this error:

"message": "Failed to retrieve the document:MongoError: Error=2, Details='Response status code does not indicate success: 
BadRequest (400); Substatus: 0; ActivityId: d05b7772-3252-4005-898f-4480cadfb8e1; Reason: 
(Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 
d05b7772-3252-4005-898f-4480cadfb8e1; Reason: (Response status code does not indicate success: BadRequest (400); 
Substatus: 0; ActivityId: d05b7772-3252-4005-898f-4480cadfb8e1; Reason: (Message: {\"Errors\":
[\"The index path corresponding to the specified order-by item is excluded.\"]}\r\nActivityId: d05b7772-3252-4005-898f-4480cadfb8e1, 
Request URI: /apps/e118124c-80f3-408e-a2f9-fbea51664ad4/services/5cb63213-f046-49d6-9825-0bfa4010772e/partitions
/68271031-2d85-44cd-9929-8857ff69b63e/replicas/132696733163313635s/, 
RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, 
SDK: Windows/10.0.17763 cosmos-netstandard-sdk/3.18.0);););"

Does it mean without having an index, we can not do a sort on MongoDB?

Wondering is this the MongoDB behavior or the CosmosDB behavior? Not sure.

Second issue is: I want to have a string search across all fields, like this:

 collection.find({"$text":{"$search":"findMeOut"}});

However here I am seeing this Mongo Error:

MongoError: $text not supported

Now what this means?

I am using CosmosDB MongoDB API using JavaScript and and NodeJs native MongoClient with the following versions:

 "mongodb": "^3.6.10",
 "fastify-mongodb": "^2.0.1",

Thanks.

1
  • What is the fix for this issue? Commented Oct 18, 2021 at 11:27

1 Answer 1

1

Sharing your model will really help. AFAIK, in order to use the text search, you've to index the fields you wanna perform search on with index name text. You can take a look at this issue which is similar to your problem I believe

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.