Index all fields or a key/value entry #2128
-
The documents I'm deading with can have properties (key/value) where the keys are provided by the users in real time while creating new data, like a name or email property. Since I don't know when loading the database all possible key names, I can't really create an index… hence I don't know how to efficiently search through them. And I'd like to avoid re-openning the database everytime a new field is added as this seems fairly inneficient and I'm worried that reloading the database might break the svelte UI listeners. Any idea? Is the only approach to create two tables, one for the objects and known entries, and one that maps object id, key, and value, with a compound index on id + key? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can have a mutliEntry indexed property (maybe 'tags' or 'indexedValues'. Then you can choose at runtime which fields to index by storing them also there. A search query is also simpler as it doesn't need to combine multiple properties. |
Beta Was this translation helpful? Give feedback.
You could take one of two approaches.
Using this approach you would serach like this: