-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the new Facet response Optional. #4907
Comments
Thank you for helping me raising the issue upon. |
I second this. Please update the docs to reflect this change in behavior or re-add the "Facets on scalar predicates" feature which was a nice touch imo. Having to manually set the facet of each corresponding node after getting the query response will definitely lead to some hacky code. |
@mileung Facets on scalar are okay. What was changed is facets in entities or List Type https://docs.dgraph.io/query-language/#list-type |
Will upcoming versions of Dgraph bring back the old behavior like?
This new behavior is difficult to work with in examples like this where ideally, the facets should be like
|
We are still working on it. |
I think if the facet is attached to the object, then let's put the facet inside the object. If it is a list of scalar values, then we can use the map. |
Hi all, we have discussed facets format internally and prepared one document with different possible formats. Please checks below discuss post and provide your feedback. |
Fixes: #4798, #4581, #4907 DGRAPH-1109, DGRAPH-1062, DGRAPH-1143 This is PR changes facets format as discussed in the post: https://discuss.dgraph.io/t/facets-format-in-mutation-requests-and-query-responses/6416 After this PR is merged response/requests formats will look like as below: Current UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California" }, "state|capital": false } ] } } New UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California", "state|capital": false } } ] } } Current UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish" }, { "name": "Chinese" } ], "speaks|fluent": { "0": true, "1": false } } ] } } New UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish", "speaks|fluent": true }, { "name": "Chinese", "speaks|fluent": false } ] } ] } } Current scalar list predicate facets mutation request: { "set": [ { "uid": "_:1", "nickname": "Joshua", "nickname|kind": "official" }, { "uid": "_:1", "nickname": "David" }, { "uid": "_:1", "nickname": "Josh", "nickname|kind": "friends" } ] } New scalar list predicate facets mutation request: { "set": { "uid": "_:1", "nickname": ["Joshua", "David", "Josh"], "nickname|kind": { "0": "official", "2": "friends" } } } NOTE: there is no change in the request/response facets format for scalar predicate type.
Fixed in #5424 |
Fixes: hypermodeinc#4798, hypermodeinc#4581, hypermodeinc#4907 DGRAPH-1109, DGRAPH-1062, DGRAPH-1143 This is PR changes facets format as discussed in the post: https://discuss.dgraph.io/t/facets-format-in-mutation-requests-and-query-responses/6416 After this PR is merged response/requests formats will look like as below: Current UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California" }, "state|capital": false } ] } } New UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California", "state|capital": false } } ] } } Current UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish" }, { "name": "Chinese" } ], "speaks|fluent": { "0": true, "1": false } } ] } } New UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish", "speaks|fluent": true }, { "name": "Chinese", "speaks|fluent": false } ] } ] } } Current scalar list predicate facets mutation request: { "set": [ { "uid": "_:1", "nickname": "Joshua", "nickname|kind": "official" }, { "uid": "_:1", "nickname": "David" }, { "uid": "_:1", "nickname": "Josh", "nickname|kind": "friends" } ] } New scalar list predicate facets mutation request: { "set": { "uid": "_:1", "nickname": ["Joshua", "David", "Josh"], "nickname|kind": { "0": "official", "2": "friends" } } } NOTE: there is no change in the request/response facets format for scalar predicate type.
Experience Report
What you wanted to do
Query for facets and return it in an ideal format (which was the original behavior).
What you actually did
Query for my node and it returns an unwanted format that breaks my application.
Why that wasn't great, with examples
The PR #4267 has done a good and welcome change in Facet's behavior to solve an issue with List Type and Facets (adding support to facets on lists). Which is great. But, this breaks how things used to be done in Dgraph. And several users had to change their application or are blocked without fully understanding Facet's behavior. Confusing the process completely.
We explain in our docs how a JSON object is treated in Dgraph
e.g:
This object above explains in a logical way to the user how a facet should be treated (And indirectly we demonstrate how the structure would be in the response of a query with facets). However, when making a query we receive the same object in a completely different format. In a format that should be optional and perhaps mandatory for List Type only.
This format above should be optional and bellow the default
Despite the change, this behavior does not affect the Value Facet at all.
If you query for:
you gonna see (which is the previous behavior)
Users are getting a bad experience from it.
Maybe we should make this behavior optional. Making possible to use the normal response (as always did) and a “map” response(as it is today).
e.g:
Any external references to support your case
https://docs.dgraph.io/mutations/#facets
https://discuss.dgraph.io/t/the-query-result-of-dgraph-v1-2-1-about-facets-looks-strange-did-i-miss-anything/5992
#4798
https://discuss.dgraph.io/t/facets-on-relations/5906
https://dgraphlabs.slack.com/archives/CSH96QK62/p1581011255272800
https://dgraph.slack.com/archives/C13LH03RR/p1583814358358000?thread_ts=1583813815.357600&cid=C13LH03RR
The text was updated successfully, but these errors were encountered: