MongoDB - Autocomplete - Get all words starting with X
问题 I have a collection (users) with the following structure: { propA: { words: ["i", "have", "an","important", "question"] } } I want to get autocomplete options from the db for some input in my website. So first, i think that i need to create an index for propA.words. Maybe something like this(?): db.users.createIndex({ "propA.words" : 1 }) Second, how can i query this index to get all the words starting with X? For example, for the string "i", the query will retrieve ["i", "important"]. Thanks