Hi,
If I understood well with your domain to retrieve the most ranked
translation you could do:

select from ( select expand( out('translatesTo') ) from Label where name =
'Hello' ) order by out_translatesTo.size() desc

To look to the direct translation in French:

select from ( select expand( out('translatesTo') ) from Label where name =
'Hello' ) where out('is') in 'Fr-fr' order by out_translatesTo.size() desc

Now to pass by any other words you could do:

select *, $depth from (
  traverse both('translatesTo') from (
    select from Label where name = 'Hello' )
  while $depth < 4 )
where $depth > 0 and out('is').name IN 'Fr-fr' order by $depth

Note the order by: the shortest path is on the top.

Or you could start playing on the concept of "shortestPath" to find the
shortest path between the word "Hello" and the "French" language:

select shortestPath( $from, $to ).asString() let $from = ( select from
Label where name = 'Hello' ), $to = (select from Language where name =
'Fr-fr') )

Result:

[v(Label)[#13:0], v(Label)[#13:2], v(Language)[#12:2]]


Lvc@


On 16 January 2014 17:47, SHak <[email protected]> wrote:

> So I'm trying to figure an approach to my previous reply and I hit another
> problem. As soon as I give my edge a property, the query that I'm using
> stops working and won't return anything that has properties, seems that the
> in/out is now with the edge and not between the labels and that of course
> affects the result greatly.
>
> Before I add the property, the result is 3 records after I add the
> properties to my edge, it's only one record.  When I do select from label,
> I see that "in_translateTo" is another class.
>
> How can I rewrite this query to get the proper 3 records?
>
> Please use setup below to reproduce.
>
> *Query*
> =====
> Select from (traverse out('translatesTo') from (select from Label where
> name = 'Hello')) where out('is').name contains 'Fr-fr'
>
>
> *setup*
> ===========================================================
> #drop database if already exists
> drop database remote:/locahost/touca root pass;
>
> #create touca database
> create database remote:localhost/touca root pass local;
>
> #create classes/Vectors
> create class User extends V;
> create class Language extends V;
> create class Label extends V;
>
> #create Links/Edges
> create class speaks extends E;
> create class is extends E;
> create class translatesTo extends E;
>
> #create User Data
> create vertex User set name = 'Luca';
> create vertex User set name = 'Joe';
>
> #create Language Data
> create vertex Language set name = 'En-uk';
> create vertex Language set name = 'En-us';
> create vertex Language set name = 'Fr-fr';
> create vertex Language set name = 'Ru-ru';
> create vertex Language set name = 'Ar-sy';
>
> #create Label Data
> create vertex Label set name = 'Hello';
> create vertex Label set name = 'Salut';
> create vertex Label set name = 'Ciao';
> create vertex Label set name = 'Good day';
> create vertex Label set name = 'Bonjour';
> create vertex Label set name = 'Hallo';
> create vertex Label set name = 'Marhaba';
>
> #index
> create property speaks.out LINK;
> create property speaks.in LINK;
> CREATE INDEX unique_speaks ON speaks (in, out) UNIQUE;
>
> #create property translatesTo.out LINK;
> #create property translatesTo.in LINK;
> #CREATE INDEX unique_translatesTo ON translatesTo (in, out) UNIQUE;
>
>
> #create the links between the User->Language
> create edge speaks from (select from User where name = 'Luca') to (select
> from Language where name = 'En-uk');
> create edge speaks from (select from User where name = 'Luca') to (select
> from Language where name = 'En-us');
> create edge speaks from (select from User where name = 'Luca') to (select
> from Language where name = 'Fr-fr');
> create edge speaks from (select from User where name = 'Luca') to (select
> from Language where name = 'Ar-sy');
>
> create edge speaks from (select from User where name = 'Joe') to (select
> from Language where name = 'En-uk');
> create edge speaks from (select from User where name = 'Joe') to (select
> from Language where name = 'En-us');
>
> #create the links between label and language
> create edge is from (select from Label where name = 'Hello') to (select
> from Language where name = 'En-uk');
> create edge is from (select from Label where name = 'Hello') to (select
> from Language where name = 'En-us');
> create edge is from (select from Label where name = 'Salut') to (select
> from Language where name = 'Fr-fr');
> create edge is from (select from Label where name = 'Ciao') to (select
> from Language where name = 'Fr-fr');
> create edge is from (select from Label where name = 'Good day') to (select
> from Language where name = 'En-uk');
> create edge is from (select from Label where name = 'Bonjour') to (select
> from Language where name = 'Fr-fr');
> create edge is from (select from Label where name = 'Hallo') to (select
> from Language where name = 'Ru-ru');
> create edge is from (select from Label where name = 'Marhaba') to (select
> from Language where name = 'Ar-sy');
>
> #create the links between labels
> create edge translatesTo from (select from Label where name = 'Hello') to
> (select from Label where name = 'Good day');
> create edge translatesTo from (select from Label where name = 'Hello') to
> (select from Label where name = 'Hallo');
> create edge translatesTo from (select from Label where name = 'Hello') to
> (select from Label where name = 'Salut') SET ncount = 5;
> create edge translatesTo from (select from Label where name = 'Hello') to
> (select from Label where name = 'Ciao') SET ncount = 10;
> create edge translatesTo from (select from Label where name = 'Good day')
> to (select from Label where name = 'Bonjour');
> create edge translatesTo from (select from Label where name = 'Bonjour')
> to (select from Label where name = 'Marhaba');
> create edge translatesTo from (select from Label where name = 'Hallo') to
> (select from Label where name = 'Marhaba');
>
>
>  --
>
> ---
> 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/groups/opt_out.
>

-- 

--- 
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/groups/opt_out.

Reply via email to