1

I am having trouble implementing an Atlas Search on a document collection where the documents have no fixed field names. All the field names are highly dynamic.

For Example, A user may create a document with the following fields

{
  name: string,
  description: string
}

Another user may create a document with the following fields

{
  company: string,
  username: string
}

This is happening because we provide a feature to users where they can create their own records. So the fields are also dynamic depending on their needs. No, we need to provide Full-Text Search Support on these documents but we are struggling to create a Search Index because the path is dynamic.

Is there any way in Mongo Atlas Search to accomplish this?

BadPiggie
  • 5,471
  • 1
  • 14
  • 28

1 Answers1

2

Yes, when you define the collections [field mapping] you want to define it as dynamic:

You can configure Atlas Search to automatically index all the supported field types in the collection using dynamic mappings.

There are some limitations by doing this but it does not sounds like it will affect you.

You then can execute a wildcard field search

Tom Slabbaert
  • 21,288
  • 10
  • 30
  • 43
  • Thank you. I tried it. But I get `MongoError: index is not allowed in this atlas tier` error. I checked limitations for the `Free Tier` but found nothing related to `index`. Any idea? https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/ – BadPiggie Jul 27 '22 at 15:41
  • 1
    I guess it is as the message says, this is just not a free tier feature. I think your only option is to restructure the data – Tom Slabbaert Jul 28 '22 at 06:07
  • Thank you for ur support. Actually, the error was misleading. There are no such limitations, The issue was some `JSON` issue. By the way, `wildcard` won't be helpful in this case because we need to search on a specified field. Anyway, I resolved the issue using `Text` instead of `Autocomplete` with `Dynamic Index` coz the `Autocomplete` not working with `Dynamic Index`. – BadPiggie Jul 29 '22 at 06:48