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

Add other filters to expand() #5803

Closed
MichelDiz opened this issue Jul 2, 2020 · 5 comments
Closed

Add other filters to expand() #5803

MichelDiz opened this issue Jul 2, 2020 · 5 comments
Labels
area/querylang/expand Issues related to expand queries. area/querylang/function dgraph Issue or PR created by an internal Dgraph contributor. exp/intermediate Fixing this requires some experience with the project. kind/enhancement Something could be better. Stale status/accepted We accept to investigate/work on it.

Comments

@MichelDiz
Copy link
Contributor

Experience Report

reference: https://discuss.dgraph.io/t/how-to-find-relationship-between-two-nodes/7495/3?u=micheldiz

What you wanted to do

Use expand func to reduce hard typing. This increases the users experience.

{
	M as var(func: type(Person)) @filter(eq(name, 'Martin Sheen')
	O as var(func: type(Person)) @filter(eq(name, 'Oliver Stone')

	q(func: uid(O) @recurse(depth: 50, loop: true) {
		expand(User) @filter(uid(M))
	}
}

What you actually did

{
	M as var(func: type(Person)) @filter(eq(name, 'Martin Sheen')
	O as var(func: type(Person)) @filter(eq(name, 'Oliver Stone')

	q(func: uid(O) @recurse(depth: 50, loop: true) {
		friend @filter(uid(M))
		~friend @filter(uid(M))
		follows @filter(uid(M))
		~follows @filter(uid(M))
             # maybe even more edges to add (...)
	}
}

Why that wasn't great, with examples

The only problem is that you need to hard type all possible edges to accomplish that. Using "Expand(Type)" with a filter it would catch all possible edges from the Type Definition and apply the filter as a "template".

@MichelDiz MichelDiz added kind/enhancement Something could be better. exp/intermediate Fixing this requires some experience with the project. status/accepted We accept to investigate/work on it. area/querylang/expand Issues related to expand queries. area/querylang/function labels Jul 2, 2020
@MichelDiz MichelDiz reopened this Jul 30, 2022
@MichelDiz MichelDiz added the dgraph Issue or PR created by an internal Dgraph contributor. label Oct 25, 2022
@dgraph-io dgraph-io deleted a comment from minhaj-shakeel Jan 2, 2023
@rderbier rderbier added kind/bug Something is broken. and removed kind/enhancement Something could be better. labels Jan 3, 2023
@rderbier
Copy link
Contributor

rderbier commented Jan 4, 2023

Postman repro case https://cloudy-astronaut-679688.postman.co/workspace/e8602b95-3843-46e0-8f3b-2d994602fa7a/collection/24547389-2ebb8f27-7be7-4493-a152-dca9b4782b5b?action=share&creator=24547389

using predicate "in" with @reverse.
you can declare the predicate "~in" in a type.
expand(all) will work : it will follow all the relationships declared in the node type, so it will follow ~in if present.
in our case the ~in relationship goes to a node of type "N5803".
If we expand(all) @filter(type(N5803)) , the query does not follow the ~in relationship. See the postman test with other options working.

@MichelDiz
Copy link
Contributor Author

The link isn't working for me.

You don't have access
To access this page, switch to an account with permission. You are signed in as michel

But I don't get your point. Are you saying that expand function has filters? last time I checked the code it wasn't.

@dwilson1988
Copy link

https://dgraph.io/docs/query-language/expand-predicates/#filtering-during-expand expand supports type filters only, but they do not work on reverse predicates.

@rderbier rderbier added kind/enhancement Something could be better. and removed kind/bug Something is broken. labels Jan 4, 2023
@rderbier
Copy link
Contributor

rderbier commented Jan 4, 2023

my bad not reading this issue correctly.
We must open a separate issue... I'll do it.

Copy link

github-actions bot commented Aug 3, 2024

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.

@github-actions github-actions bot added the Stale label Aug 3, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/querylang/expand Issues related to expand queries. area/querylang/function dgraph Issue or PR created by an internal Dgraph contributor. exp/intermediate Fixing this requires some experience with the project. kind/enhancement Something could be better. Stale status/accepted We accept to investigate/work on it.
Development

No branches or pull requests

5 participants