When I am writing queries, I met these questions:
- For this query,
{
person(func: uid("0x59179e7")) {
~hasCreator{
uid
content
imageFile
creationDate
replyOf{
uid
}
}
}
}
some results contain the replyOf
and some results just contain the other four properties. If I just want to ouput the results that contain replyOf
, how should I write the query.
Part of the results are showed as:
{
"uid": "0x593034e",
"content": "",
"imageFile": "photo824633721183.jpg",
"creationDate": "2012-01-27T10:01:24.389Z"
},
{
"uid": "0x5930fff",
"content": "thx",
"creationDate": "2012-06-03T11:51:59.268Z",
"replyOf": [
{
"uid": "0x5bab63a"
}
]
},
I have tried the @casscade
, like
{
person(func: uid("0x59179e7")) {
~hasCreator @cascade{
uid
content
imageFile
creationDate
replyOf{
uid
}
}
}
}
, but could not get any results.
2. How to transfer the value to the nested subqueries. I tries the query like this:
{
University(func: eq(type, "University")){
A as uid
~undergraduateDegreeFrom @filter(eq(type,"GraduateStudent")){
memberOf @filter(eq(type, "Department")){
subOrganizationOf @filter(eq(type, "University") AND uid(A)))){
uri
}
uri
}
uri
}
}
}
the inner University should be the same as the outer University. But this query got grammatical errors.
3.How to limit the number of the final results?
In Cypher or Gremlin, we can limit the number of the final results, like
MATCH (person:Person)<-[:HAS_CREATOR]-(m:Comment)-[:REPLY_OF*0..3]->(p:Post)-[:HAS_CREATOR]->(c)
WHERE id(person) == 'person_933'
RETURN
id(m) AS commentId,
m.content AS messageContent,
m.creationDate AS messageCreationDate,
id(p) AS originalPostId,
id(c) AS originalPostAuthorId,
c.firstName AS originalPostAuthorFirstName,
c.lastName AS originalPostAuthorLastName
ORDER BY messageCreationDate DESC
LIMIT 10
but DQL seems could only limit the number in a certain level, like:
{
me(func: allofterms(name@en, "Steven Spielberg")) {
director.film (first: -2) {
name@en
initial_release_date
genre (orderasc: name@en) (first: 3) {
name@en
}
}
}
}
the number could be calculated as 2*3=6, but if I just want to get 5 results, how could I write the query.
4. For the recurse queries.
MATCH (:Person {id: $personId})<-[:HAS_CREATOR]-(m:Message)-[:REPLY_OF*0..]->(p:Post)
In cypher, we can denote the depth of a predicate, like [:REPLY_OF*0..]
, but in DQL how to write query like this?