Reputation:
I have objects with keywords nested in various depths, which I want to store in an index. The keywords are formatted as so:
{
"list": [
{
"keywords": ["hi", "bye"],
"rules": "contains 1 of the following"
},
{
"keywords": ["foo", "bar"],
"rules": "contains all of the following"
}
]
}
I want to search all the keywords at once, then loop back through the "list" with the matches to find similarities. I was wondering whether it was best store all the keywords separately in another table or loop through each of the list and search the keywords with a new regex each time, bare in mind there are thousands of these lists.
Upvotes: 3
Views: 1395
Reputation: 18730
{prop1:value1,prop2:[value2,value3]}
, and you create an index on prop2, and you use the multi-entry flag to the createIndex API method, then two rows would appear in the index, one for value2 and one for value3. You could then open a cursor on this index and iterate over its rows, first seeing value2 and then seeing value3 (depending on order). This would be the source of the array you build and load into memory and then separately, in memory, loop over using your own regex test condition.{prop:word}
. You could then open a cursor on this store and iterate over all the words to build the same in memory array over which you then iterate and test with your regex.Upvotes: 3