This bug report may or may not be related to the supposed fix: https://github.com/dgraph-io/dgraph/pull/3190
https://github.com/dgraph-io/dgraph/issues/3163
Schema:
op.Schema = `
user: bool .
user.name: string @index(hash) .
user.email: string @index(hash) .
user.password: password .
user.code: string .
user.created_at: dateTime .
user.validated: bool @index(bool) .
node: bool .
node.hashid: string @index(hash) .
node.owner: uid @reverse .
node.parent: uid .
node.xdata: string .
node.searchable: bool @index(bool) .
node.search_title: string @index(term) .
node.search_synopsis: string @index(fulltext) .
node.created_at: dateTime .
`
query:
q = `
query withvar($hashid: string) {
chain(func: eq(node.hashid, $hashid)) @recurse(loop:false) {
uid
node.owner
user.name
node.hashid
node.xdata
node.parent @facets @facets(%s)
}
}
`
json result:
{
"chain": [
{
"uid": "0x4e27",
"node.owner": [
{
"uid": "0x1",
"user.name": "alpha"
}
],
"node.hashid": "jjtn4cdirv",
"node.xdata": "",
"node.parent": [
{
"uid": "0x4e23",
"node.owner": [
{
"uid": "0x1",
"user.name": "alpha"
}
],
"node.hashid": "17t8kc5ig",
"node.xdata": "",
"node.parent|facet": "recommended"
},
{
"uid": "0x4e25",
"node.owner": [
{
"uid": "0x1",
"user.name": "alpha"
}
],
"node.hashid": "r9t9rc4ip",
"node.xdata": "",
"node.parent": [
{
"uid": "0x4e23",
"node.hashid": "17t8kc5ig",
"node.xdata": "",
"node.parent|facet": "recommended"
}
],
"node.parent|facet": "recommended"
},
{
"uid": "0x4e26",
"node.owner": [
{
"uid": "0x1",
"user.name": "alpha"
}
],
"node.hashid": "35t8qc8i5",
"node.xdata": "",
"node.parent": [
{
"uid": "0x4e23",
"node.hashid": "17t8kc5ig",
"node.xdata": "",
"node.parent|facet": "required"
},
{
"uid": "0x4e25",
"node.hashid": "r9t9rc4ip",
"node.xdata": "",
"node.parent|facet": [
"recommended",
"recommended"
]
}
],
"node.parent|facet": "required"
}
]
}
]
}
"node.parent|facet" should return a string.The BUG:
The second last "node.parent|facet" returns an array which should not be the case.
You can see the full query here: https://github.com/thehonestscoop/lemma-chain/blob/master/find_chain.go
@martinmr, was this bug a side effect of your PR?
It doesn't seem related. It only affects one of the nodes at the end of the chain. The PR you mentioned affects all of them Can you query the facet on that node directly to see what you get?
Can you query the facet on that node directly
What does that mean? You mean query that node (eg. "uid": "0x4e25")
In the meantime, is it safe for me (as a temporary fix) to get the first item from array?
Yes, that's what I mean. It should be safe to check if you have an array and just get the first one.
Also, there shouldn't be two @facets directives in your query. At least when I run a similar query using https://docs.dgraph.io/query-language/#facets-on-scalar-predicates I get an error message saying multiple @facets are not allowed. Either you get all the facets or you only get one of them.
I believe there were good reasons why I had to add the @facets @facets(eq(facet, "required") or eq(facet, "recommended")). Either way it produces no dgraph errors and produces the expected results.
Let me investigate the @facets @facet(%s) issue further since you say it should not be permitted.
@power-f-GOD can you run the query with the ref r9t9rc4ip and 35t8qc8i5 to answer @martinmr's question. You will need to fmt.Println( ) the response back from DGraph.
Okay. Do you mean to run the query that produced the error again?
I investigated it further.
When I ran the query for the earlier nodes, the results were a string (not an array) for "node.parent|facet"
Something is clearly wrong with the array being returned.
Sorry for the late reply. What are the triples you inserted for this node (triples where this node is the subject) and how do they compare against a node where you can get the right result? I don't need the data but I think this comparison could enlighten us on what's different about this node.
If you insert those triples into a clean instance of Dgraph and run the query, is the result still showing the facet as an array or as a string?
I am beginning to think this issue might not be related with the query code given how other nodes return properly formatted data.
what's a triple?
what should I do to investigate (in simpler terms)?
My query contains: @facets @facets(eq(facet, "required") or eq(facet, "recommended")).
You said to remove the first @facets. I then doesn't return any facets.
Ok. I guess I didn't understand why the two @facets are needed.
Triples: https://docs.dgraph.io/mutations/#triples
Since you don't know what these are I am guessing you are using JSON to insert data into dgraph but what I meant was to add the data for this node into a new cluster, run the query (or a similar query checking the facets) and check if the query still returns an array.
Hi there, @pjebs
I'm trying to understand your issue here but I don't see how you could have been able to run the query you gave on the issue.
You are requesting @facets twice on the same predicate, which is not allowed.
Could you confirm what's your real query and give a sample of your dataset so we can try it out?
Thanks
It definitely works pre v1.1. Maybe it's been corrected v1.
The full query is: https://github.com/thehonestscoop/lemma-chain/blob/master/find_chain.go#L202
What is the thing that works pre v1.1?
Querying for facets twice or the recursive expansion you're requesting?
I haven't been able to get a node with two values for the same facet.
Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.
