Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

How to adjust mongoose query for Atlas Search?

$
0
0

This is my Index Definition in Monodb Atlas Search.

{"mappings": {"dynamic": false,"fields": {"title": {"type": "string"      }    }  }}

This is my query.

const searchPipeline = ({query}) => {  return [    {      $search: {        index: "default",         text: {          query,          path: ["title"],           fuzzy: {            maxEdits: 2,             prefixLength: 1,           },        },      },    },  ];};

Problem is that when query is "audi a2" it matches everything that has "audi" in title. I want it to behave following way:

  1. query="audi" -> match everything with "audi" in title
  2. query="audi a2" -> match everything with "audi a2" in title but not "audi a1", "audi a3" etc...

I'm not into BE much but I am learning new stuff at the moment. ChatGPT wasn't helpful at all.


Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>