Skip to content
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

remove reflexive edges from results #899

Closed
MichaelJCompton opened this issue May 4, 2017 · 5 comments
Closed

remove reflexive edges from results #899

MichaelJCompton opened this issue May 4, 2017 · 5 comments
Assignees
Labels
kind/feature Something completely new we should consider.
Milestone

Comments

@MichaelJCompton
Copy link
Contributor

MichaelJCompton commented May 4, 2017

Add a directive to remove self edges from results. For example, in the following query, to remove actors as co actors of themselves.

{
  coactors(func:allofterms(name, "Jane Campion")) @cascade @normalize {
    JC_films as director.film {      # JC_films = all Jane Campion's films
      starting_movie: name
      starring {
        JC_actors as performance.actor {      # JC_actors = all actors in all JC films
          actor : name
          actor.film {
            performance.film @filter(not var(JC_films)) {  # find a different film
              film_together : name
              starring {
                # find a coactor who has been in some JC film
                performance.actor @filter(var(JC_actors)) {
                  coactor_name: name
                }
              }
            }
          }
        }
      }
    }
  }
}
@MichaelJCompton
Copy link
Contributor Author

Actually, maybe this isn't enough. In this case, how to specify where I want the duplicates removed from - it's not a simple self referential edge, and never would be in a the movie dataset because it's quite a few edges from an actor to their co-actors.

The most general mechanism seems to be to be able to accumulate variables specific to the current branch in the query, rather than globally. In this case, it looks like both global and local are required.

@ashwin95r
Copy link
Contributor

ashwin95r commented May 4, 2017

We don't need a direct self-referential edge. Providing the directive would mean that a uid cannot be its own child at any level.

The most general mechanism seems to be to be able to accumulate variables specific to the current branch in the query, rather than globally. In this case, it looks like both global and local are required.

This might be too expensive given our design I feel.

@manishrjain manishrjain added this to the No Deadline milestone May 5, 2017
@manishrjain manishrjain added the kind/feature Something completely new we should consider. label May 5, 2017
@MichaelJCompton
Copy link
Contributor Author

What if uid was assigned to a value variable and then used in filters?

q(...) {
  myid as _uid
  ...
  some { edges { later @filter(NOT(var(myid))) } }
}

This syntax is accepted at the moment, but I guess after following other edges, it's no longer the correct context to use myid.

@pawanrawal
Copy link
Contributor

@MichaelJCompton That might work in case of a single starting node but wont work as desired for multiple starting nodes as you would want to only remove the starting node from a particular tree path.

@pawanrawal
Copy link
Contributor

This is now supported and has been merged to master.

@manishrjain manishrjain added the kind/feature Something completely new we should consider. label Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something completely new we should consider.
Development

No branches or pull requests

4 participants