0
votes

I have projects that have "name" as a property and I want to generate a list of the duplicates. I tried to do this by grouping the projects by name, and using the where clause to filter the results where the count of the project name is greater than 1 and showing those names.

The below generates a list of the project names with the count of each
g.V().hasLabel('project').groupCount().by('name')

So I added the filter to find only the duplicate values and it does not work:
g.V().hasLabel('project').groupCount().by('name').where(select(values).is(gt(1))).values('name')

2

2 Answers

0
votes

You need to unfold() the count Map(), thus:

g.V().hasLabel('project').
  groupCount().
    by('name').
  unfold().
  where(select(values).is(gt(1))).
  values('name')

If you don't unfold(), you have a Map in the pipeline and it tries to apply your where() to that object as a whole when you really want to apply it to each individual key/value pair in the Map.

0
votes

This worked for me:

g.V().hasLabel('project')
.group().by(values('name')
.fold()).unfold().filter(select(values)
.count(local).is(gt(1))).select(keys)