Reputation: 31
I have multiple documents. I have multiple users. Users read documents.
I want to get documents that were read by user Stefan.
g.V().
has('user','name','Stefan').
out('read').
hasLabel('document')
What other users has read the same document? And what other documents are those users reading which the user Stefan doesn't have:
g.V().
has('user','name','Stefan').
out('read').
hasLabel('document').
in('read').
has('user','name',neq('Stefan')).
out('read').
match(
__.as('d').hasLabel('document'),
__.not(__.as('d').hasLabel('document').in('read').has('user','name','Stefan'))
).
select('d').valueMap('docId','title')
Now I want to sort this by the number of user that read the document with groupCount.
g.V().
has('user','name','Stefan').
out('read').
hasLabel('document').
in('read').
has('user','name',neq('Stefan')).
out('read').
match(
__.as('d').hasLabel('document'),
__.not(__.as('d').hasLabel('document').in('read').has('user','name','Stefan'))
).
select('d').valueMap('docId','title').
groupCount().by().
order(local).by(values,decr)
This will work, but the result is not what I want:
{
"{docId=[33975], title=[Doc1 - 5 - 1]}": 3,
"{docId=[33379], title=[Doc2 - 5]}": 2,
"{docId=[32474], title=[Doc3 - 5]}": 2,
"{docId=[31150], title=[Doc4 2-2013]}": 1,
"{docId=[107944], title=[Doc5]}": 1
}
The key is folded. I want to have 3 columns in my result:
How can I do this?
Upvotes: 0
Views: 35