The idea of having the first name inside the node “family”, does not make much sense to me. Could you elaborate? If a family has multiple “Bob” how you can keep each “Bob” unique? You should create a “tree” for it oO. It is better that there is a family name then you filter by the family name you want to find.
In that case to see what family the user is. You need to put family as “@reverse”. If the family has to be unique, you must give a single markup for each or “save/collect/keep” your UIDs in another way.
Can you try this?
{
var(func: has(family)) {
family @filter(allofterms(name@en, "Bennett Russell Diaz")) {
~family {
myVar AS uid
}
}
}
userWithfamily(func: uid(myVar), orderasc: name) {
name@en
age
family {
family_name
}
}
}
@MichelDiz I was thinking about allofterms. In my case I have two not connected nodes with different predicates. I like your query. But this is not what is was looking for.
Example: logging_status has logger_name string predicate.
{
query(func: has(logging_status))
{
logger_name // 'john' , 'mike', 'jacho' <= i need to save this result as a variable ex: logger_name_results,
}
query2(func: has(loggers)) @filter(allofterms(name, logger_name_results) )
{
expand(_all_)
}
}
So I need to get all names from logging_status and check if loggers name matches one of the logging_status logger_name, if they match return all.
Any ideas how to do it?
I still do not understand your purpose. It’s clear what it says, but for me it’s vague when what the Dgraph can do for you. In Dgraph there is no comparison of strings as far as I know (except for password comparison https://docs.dgraph.io/query-language/#extended-types). You can make two query blocks and then compare in your application. I think that would be the most Dgraph could do for you on this issue.
This your sample query may work, but it is not accurate as to the user’s identity. Having said that, I do not understand the intent.
@omurbekjk all identification needs to be unique. That way either you need to create your aproach in your bussines-logic(aplication layer) or you use the Dgraph functionality in connecting nodes trought UID.
For example, you will aways have more than one John. Soon that identification you need to compare needs to be unique.
Instead of sending “john” you could send the UID of John’s node. Since it seems to me that in this last query you want to queue. A queue of logged users right?
One note, in your query you are using two query blocks. The first must be “var” to be a variable block.
I’m not sure if this query below can work. I did not test it.
{
var(func: has (logging_status))
{
n_Results AS logger_name
}
query (func: has (loggers)) @filter (allofterms (name, n_Results))
{
expand (_all_)
}
}