I have a model with entities which includes parent keys. I want to know if it's possible to make a specific query to obtain only the keys of the parents given some attribute restrictions on the children entities.
I'll try to give an example. Suppose that we have names of persons, their parent (just the key), and their favorite color:
| Name | Parent | Color | ----------------------------- | Robert | Albert | Yellow | | Rupert | Albert | Yellow | | Gilbert | Albert | Green | | Q-bert | Rupert | Yellow |
I want a query to obtain the following list without repeated elements as a result, when querying for the color Yellow
: < Albert, Rupert >
.
Notice that I'm not interested in the children, just the keys of the parents. Note also that although I could group the repeated keys in a Set<Key>
that would break the paging of my application.
I know there are no distinct
queries, but search engines usually have a "clustering" feature to accomplish this task. And I believe that the underlying organization of the Datastore is like the organization of a full-text search engine. That's why am asking.
BTW, I'm using the low-level Java Datastore API.
Thanks in advance.