Hi Artem, I have a great idea to solve my issue that I think will work but 
I need your expertise.

I was wondering, I would like to avoid a complicated traversal solution as 
you mention with gremlin that could be a lot more expensive (I still cannot 
get gremlin working out of the box).  But would like to continue using SQL. 
 So I've been thinking...could the following be done?

Select using the query you provided before excluding the direct connections 
from the result.  then do another select that goes only 1 depth and get the 
count on the edges and finally do a union of both and order by count.  Not 
sure what the syntax would be so I'll pseudo code it and maybe you can let 
me know if it's possible?

I understand that it'll run 2 queries but probably not expensive overall 
especially that the 2nd query is direct links only.

Select name, count from

UNION
{
    select *name, null as count* from (traverse out('translatesTo') from 
(select from Label where name = 'Hello')) where out('is').name contains 
'Ar-sy' *EXCLUDE FIRST LEVEL*
}
WITH
{
    select *name,count of edge *from (traverse out('translatesTo') from 
(select from Label where name = 'Hello')) where out('is').name contains 
'Ar-sy' *LIMIT TO 1 LEVEL of depth*
}

Order by count desc 

(I regret having asked both questions here, because if we can get this 
working, I'm sure others can benefit. if we can get it working, I'll repost 
it with answer in case someone else is interested)

On Tuesday, January 14, 2014 8:10:11 PM UTC+2, Artem Orobets wrote:
>
> The idea is to find edges to the translations instead of translations 
> itself, then you can take a projection of a result into translation_name, 
> count and depth of projection. Then during processing of query result you 
> can take count value if depth = 1 or 0 otherwise.
>
> With growing of complexity of traversal logic it's become more and more 
> complicated to write a proper SQL query. Possibly make sense to take a look 
> at gremlin queries. This query language is more flexible and allow to 
> implement some queries in more simple way. However it has its cost of 
> performance, some gremlin queries can work much longer then its SQL variant.
>
>
> Best regards,
> Artem Orobets
>
> *Orient Technologies the Company behind OrientDB*
>
>
> 2014/1/14 SHak <[email protected] <javascript:>>
>
>> For those that have a direct edge, I would like to have their counts, for 
>> the others it could stay null or 0.
>>
>> If the data is structured as in the example below, Allo and Salut are a 
>> direct link while Bonjour is indirect via italian ciao.
>>
>> "Hello"->"Allo" (5 times)
>> "Hello"->"Salut" (15 times)
>> "Hello"->"Ciao"
>> "Ciao"->"Bonjour"
>>
>> if I query for french translations, it would be nice to order the result 
>> as in example below, so the most common translation is on top.  As 
>> edge/counts are added between "Hello" and "Bonjour", then we can show the 
>> most used translation on top.
>> "Salut" (15 times)
>> "Allo" (5 times)
>> "Bonjour" (null or 0 times)
>>
>>
>> On Tuesday, January 14, 2014 3:46:43 PM UTC+2, Artem Orobets wrote:
>>
>>> I'm not sure that understand usecase for second query. Do you want to 
>>> get count only of first level translation or all transitive translation of 
>>> some word (Like "Hello" -> "Marhaba")?
>>>
>>> For the first case you can simply use query like:
>>> select outV().name, inV().name, count from translatesTo where 
>>> outV().name = 'Hello'
>>>
>>> For the second one I don't understand how do you want to calculate count.
>>>
>>> Best regards,
>>> Artem Orobets
>>>
>>> * Orient Technologiesthe Company behind OrientDB*
>>>  
>>>
>>> 2014/1/14 SHak <[email protected]>
>>>
>>>> until I hear back if this is the correct approach, I'm following on my 
>>>> 2nd problem which is to order by the Edge property.
>>>>
>>>> I changed these 2 edges to have a count property
>>>>  
>>>> create edge translatesTo from (select from Label where name = 'Hello') 
>>>> to (select from Label where name = 'Good day') SET count=10;
>>>> create edge translatesTo from (select from Label where name = 'Hello') 
>>>> to (select from Label where name = 'Hallo') SET count=5;
>>>>
>>>> the problem I see is that my previous query filters to @class='Label' 
>>>> and the edge properties are of class='translateTo' and they are on a 
>>>> separate record when I run this query.
>>>>
>>>> TRAVERSE * FROM (SELECT FROM label WHERE name like '%Hello%') while 
>>>> @class = 'Label'
>>>>
>>>> I thought that maybe expand on this query might help but it's too late 
>>>> because of filter of @class, any suggestions?
>>>>
>>>>
>>>>
>>>>  -- 
>>>>  
>>>> --- 
>>>> 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] <javascript:>.
>> 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