Filter with math

Hi, I would like get all data where distance > 1000. How can I do that?
My query:

 { 
  f(func: has(ToCity)) @filter(eq(country, "PL"))
  {   
    city_ascii   
    ToCity {
      city_ascii
    }   
   Distance  
  }
}

I tried sth like this: @filter(math(Distance > 1000)) but isn’t working.
thanks for your help!

1 Like

Hi @BFine9,

To to that, you will have to use Dgraph’s built-in comparator functions,
Depending on your use case, something like @filter(gt(Distance, 1000)) will be required.

Note that to be able to run comparator functions on Distance, it will have to be indexed.

You may follow this tutorial to read more, https://dgraph.io/docs/tutorial-3/ . Specifically this.

1 Like