Is it possible to create a Text Index on dynamic fields in Mongodb for text query search?

287 views Asked by At

Is it possible to have dynamic text field creation on a text index without dropping the text index itself?

We have data coming into our Eve API layer that can have any {key: value} pair that we want to do a text search on (the key can be any string name). Right now we have it hardcoded for when we create the text indexes and on what fields, like so:

           app.data.driver.db['name_collection].create_index(
                [
                    ("first_name.text", pymongo.TEXT),
                    ("last_name.text", pymongo.TEXT),
                    
                ],
                name="text",
            )

This won't work once we introduce dynamic fields, however. Any thoughts?

0

There are 0 answers