Using a predicate in a near() condition within @filter

I was wondering if there is a way to use a predicate inside a near() conditional. Consider the following query which finds all predicates that have a model, model and either a Region predicate National or are within a location range.

{
  Searches(func: has(Search))
  @filter(
    uid_in(Make, 0x3e) AND
    uid_in(Model, 0x1a3) AND (
      eq(Region, "National") OR
      near(Location, [ 43.653908, -79.384293 ], 100)
    )
  )
  @normalize {
    UID : uid
    Title : Title
    Owner { Owner : uid }
    Location : Location
    Region : Region
  }
}

In the above I have the third parameters of near() hard coded to 100. However Search has a direct predicate called Distance that contains the boundary to search within. So ideally I’d like to write:

near(Location, [ 43.653908, -79.384293 ], Distance)

If I try that I get a response:

Error while converting distance to float error: strconv.ParseFloat: parsing "Distance": invalid syntax

I also attempted using val(Distance) but it complains about a variable not existing. One thing to note is that I believe the above parseFloat is being thrown because Distance doesn’t always exist. As a solution I considered wrapping the statement in a condition ie.

eq(Region, "National") OR near(Location, [ 43.653908, -79.384293 ], cond(Distance > 0, Distance, 0)

I’m wondering what the appropriate way of passing in Distance would be and if I’m correct in my syntax.

Thanks!

No, this isn’t possible right now and no one has asked for it. You’d have to use a float for the distance right now. Maybe specify a large value and then filter in your application for now. Also, file an issue on Github mentioning your use case and we can support it in the future if there is demand for it.

Is there any way I can use a conditional? I can possibly mutate my nodes to project -1 as a null value. Then use a cond(Distance == -1, 99999999, Distance)?

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

Conditionals aren’t possible for now.

Is there any other solution? Solving this in my app would be very impractical :frowning:

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.