Failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)

Hello

I have set up a compound index as follows:

db.Capture.createIndex({“Timestamp”: -1, “BodyHtml”: “text”})

Every time a run a query in Compass I get the following error:

failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)

The query looks like the following:

{Timestamp: {$gte: new Date(“2021-05-01T00:00:00.000-04:00”)}, $text: {$search: “Session Timeout”}}

What am I missing?

Thanks
Tom

The query part

is not

Steve

I appreciate your response, but being very new to MongoDb could explain the error a bit more? Also any kind of solution to correct my query?

Tom

You are looking for a range of Timestamp with $gte. If you were looking at a specific Timestamp with $eq the index could be use.

From the query part

I suspect that Session Timeout is the complete value of field. If it is then a normal index might be sufficient.

Since your new to MongoDB, I think it is best that you look at

and take some MongoDB university courses like M201.