Hi Santo,
try this:

select $distance as distance from cities let $distance = distance(latitude,
longitude, 51.4503729, 4.4914635) where $distance < 20

And on Graph API:

OSQLAsynchQuery<Vertex> asyncQuery = new OSQLAsynchQuery<Vertex>("select *,
$distance as distance from cities let $distance = distance(latitude,
longitude, 51.4503729, 4.4914635) where $distance < 20");

Lvc@


On 4 April 2014 14:10, sANTo L <[email protected]> wrote:

> Hi,
>
> What is the correct / recommended way to use the result of distance() in a
> where clause ?
>
> I know I can do something like this:
> select distance(latitude, longitude, 51.4503729, 4.4914635) as distance
> from cities
>
> But I can't do this:
> select distance(latitude, longitude, 51.4503729, 4.4914635) as distance
> from cities where distance < 20
>
> Of course I could do this:
> select distance(latitude, longitude, 51.4503729, 4.4914635) as distance
> from cities where distance(latitude, longitude, 51.4503729, 4.4914635) < 20
>
> But I can't imagine that would be the most optimal/recommended way, is it ?
>
>
> Also, how can I send this distance value back together with the record
> itself when using the java OrientGraph API ?
>
> Normally I'm doing something like this:
>
>         OSQLAsynchQuery<Vertex> asyncQuery = new
> OSQLAsynchQuery<Vertex>("select from cities where distance(latitude,
> longitude, 51.4503729, 4.4914635) < 20");
>         OCommandResultListener asyncListener = new
> OCommandResultListener() {
>             int resultCount = 0;
>             @Override
>             public boolean result(Object iRecord) {
>                 resultCount++;
>                 Vertex doc = graphDb.getVertex(iRecord);
>                 System.out.println("new record received (" + resultCount +
> ")");
>                 System.out.println(">> zipcode: " +
> doc.getProperty("zipcode"));
>                 return true;
>             }
>
>             @Override
>             public void end() {
>                 System.out.println("All records received: " + resultCount);
>             }
>         };
>
> But how do I add the distance to this ?
> I could probably use something like this for the query: "select @this,
> distance(latitude, longitude, 51.4503729, 4.4914635) as distance from
> cities"
>
> But what would be the result type in this case ?
>
> Or do I have to perform separate querries for this (which would cause a
> significant overhead) ?
>
>
> regards,
>
> Santo
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OrientDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to