Is there any way to retrieve only the parent keys from the Oracle NoSQL database? In other words, only the keys that have no minor components. For example, something like this:
Iterator<Key> iter = kvstore.storeKeysIterator(Direction.UNORDERED,20, parentKey, keyRange, Depth.PARENTS_ONLY);
For instance, let's say I have stored the following keys in the Oracle NoSQL db:
Then, I would like to retrieve the following keys:
Note, that at the moment I have as an alternative solution the use of a manually maintained secondary index of all the parent keys. A solution that seems to work ok, but it is not as efficient as if a Depth.PARENTS_ONLY solution would be.
Thank you very much,
By "parents only" I think you mean "major key path only". Unfortunately, the answer is no, we don't currently have such a search mode.
The only way to do a single API call to select the keys you want is to define the schema a little differently. If /WebPage is the first component, and the URL is the second component, you can use /WebPage as the parent key and specify Depth.CHILDREN_ONLY. This means that the URL, http://bar.com/1.html for example, will be a single key component rather than multiple components.
(Note that there is nothing wrong with including slashes inside a key component. The Key.toString method will escape the slashes, but the slash will not be escaped in the component string returned by Key.getMajorPath.)
If the URL consists of multiple key components, on the other hand, you'll have to query for all keys and filter out the keys you're interested in.