Below is a simplified setup to focus the discussion
Imagine these two models with the following schemas:
// Animal model schema
{
name: string @index(fulltext) .
age: int .
desexed: bool
}
// Person model schema
{
name: string @index(fulltext) .
age: int .
married: string
animals: uid .
}
And the following query:
query users($a: name) {
usersbyname(func: eq(name, $a)) {
{
name,
age,
sex
}
}
}
Now imagine the database is full of data, we have users and animals that both have the name “Bob”.
Currently it seems I will get back both animals and users with this query. When I first tried this I really only wanted users and it surprised me that it returned both. On reflection it make sense as they are both using the same predicate “Name” (hopefully I am using this term correctly).
As animals and users have slightly different shapes my data will not have consistent fields with this query, even if I had enforced this in during creation.
So my question is what is the best way to handle this? My thoughts are:
- prefix: userName animalName (naive approach?)
- facets: add user and animal as a facet to name and filter on the facet
A concrete example you can run now highlighting the issue.
The query below is just and edit of the first query in the “Functions” section of the docs website. I just changed it from “jones indiana” to “Romance”. You can see it returns what I believe is a Genre as a primary result, which is a different shape as it does not have Genre’s of its own.