Max filter on edge facet supported?

If i include a variable on an edge between 2 nodes, can i write a single query to give me the 2 nodes with the edge with the max value of that variable?

My attempt below gives the error: “variables are not allowed in facets filter.”

My failing query:

 {  
 playlist (func:eq(dj, "damo")) {
 name:dj
 spins @facets (max(val(played_on))) {
    name:record
  }
 }
}

Data set:

 {
  set {

 _:d1 <dj> "damo" .
 _:r1 <record> "gnr" .
 _:r2 <record> "rory g" .
 _:r3 <record> "b boys" . 

  _:d1 <spins> _:r1 (played_on=1) .
 _:d1 <spins> _:r2 (played_on=2) .
 _:d1 <spins> _:r3 (played_on=3) .
  }
  }

Hey @damienburke,

One possible solution is:

{  
 result(func:eq(dj, "damo")) {
 	name:dj
 	spins @facets(orderdesc: played_on) (first:1){
    name:record
  }
 }
}

I think there can be other ways too. I will let you know if I get something. Please mark it as solved if this solves your query.

2 Likes

Thats works, thanks @ahsan
If this is only option let me know and i will mark as solved

Hey @damienburke,

I am unable to find an alternative approach for your query. The solution proposed above is the one until we start supporting value variables on facets. Hope that helps with your use-case. :slight_smile:

1 Like