MongoServerError when trying to use a pre-filter with langchain

I’m getting the following error when I try to apply a pre-filter when looking up documents using langchain and Atlas search.

MongoServerError: PlanExecutor error during aggregation :: caused by :: Path ‘chunkIndex’ needs to be indexed as number

Here’s my query

const vectorStore = new MongoDBAtlasVectorSearch(
      indexName: "default", // The name of the Atlas search index. Defaults to "default"
      textKey: "text", // The name of the collection field containing the raw content. Defaults to "text"
      embeddingKey: "embedding", // The name of the collection field containing the embedded text. Defaults to "embedding"

  const resultOne = await vectorStore.similaritySearch("Hello world", 1, {
    preFilter: {
      chunkIndex: {
        "$lte": 85,

Here’ s a sample of my metadata for each embedding item:

 "embedding": [...],
  "chunkIndex": 22,

I also created an index for chunkIndex like this

    "chunkIndex": 1

Am I missing something?

@Omnivision_Solutions - What’s the index definition for this query?

Maybe the following filter index details documentation will help.