Full Text Search (Partial Match)

I am evaluating full-text search on Atlas. I need to know that MongoDB Atlas supports partial matching. I created a database on the free tier and the search index config appears in the console. I created an index as per the instructions. I need to confirm that if a field has “text” and I search for “text” that there is a match. I also need to confirm that it is using the Lucene engine.

I can do searches but partial match does not work. I.e. searching for “text” yields a result, but “tex” yields nothig. I then saw this article and now I’m wondering if the free tier supports partial matching. Does it?

I tried creating a serverless instance but there is no config for searching there at all.

So, is it possible to do partial text matching on searches on the free tier? If not, what do I need to do to see this functionality? Which minimum level tier do I need?

Alternatively, is there a MongoDB docker image I can use that comes with Lucene search?


Should be
I need to confirm that if a field has “text” and I search for “tex” that there is a match.

I have also tried searching with tex* but this doesn’t yield results either.

Perhaps I need the autocomplete operator? If so, how would I even do an autocomplete query through the portal? Do you I need to use the API client SDK for that?

1 Like

Hey there! Yes you can use the autocomplete operator - I would make sure it is also set up correctly in your index https://docs.atlas.mongodb.com/reference/atlas-search/index-definitions/#autocomplete (can set up using our visual index builder directions here) and then use the right query in either Compass Aggregation Builder, on the Atlas Collections tab in Aggregation Builder or in the Mongoshell

Let us know if you get it!


You can use search with wildcard to achieve this. Once you’ve created a search index, you can do something like this:

db.collection.aggregate([{ $search: { wildcard: { query: '*tex*', path: { 'wildcard': '*' }, allowAnalyzedField: true }} } ]);

Beware !!!
Using this appraoch seems good. But it puts way too high load on your servers, CPU exhaustion, memory exhaustion becomes frequent if you have a decent amount of data.
Only index the fields you need and write the aggregation in a way which you think would actually be used.
For your use case :

  1. regex and wildcards : https://www.mongodb.com/docs/atlas/atlas-search/regex/#std-label-regex-ref
  2. Custom analyzers : https://www.mongodb.com/docs/atlas/atlas-search/analyzers/custom/

Hope it helps.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.