Thanks, Artem!
I have also already tried your solution. It works fine. But I think
UNIONALL is not so natural for graph databases.
Also I don't understand why
select from Location where name LUCENE 'Lon*' or out_language.in.name
LUCENE 'Lon*' limit=20
does not work.
среда, 18 июня 2014 г., 10:29:33 UTC+3 пользователь Artem Orobets написал:
>
> Hi Vladimir,
>
> In this case traverse is not really needed and might lead to unnecessary
> record reads. I also don't think that you need order by in that place. So I
> would transform query to following:
> SELECT EXPAND( $c )
> LET $a = (select in('language') from Alias where name LUCENE 'Minsk*'),
> $b = ( SELECT FROM Location where name_en LUCENE 'Minsk*' ),
> $c = UNIONALL( $a, $b )
>
>
>
> Best regards,
> Artem Orobets
>
> *Orient Technologies the Company behind OrientDB*
>
>
> 2014-06-18 9:29 GMT+03:00 Riccardo Tasso <[email protected]
> <javascript:>>:
>
>> Why are you using Lucene if you don't need full-text features?
>>
>> I would try with:
>>
>> SELECT FROM Location WHERE name LIKE 'Lon%' OR
>> out('language').name LIKE 'Lon%' LIMIT 20
>>
>>
>> 2014-06-17 13:58 GMT+02:00 Vladimir Ziankevich <[email protected]
>> <javascript:>>:
>>
>> Ouch, I was mistaken. The second query makes search only throough the
>>> aliases. I think that is a correct variant of the second query
>>>
>>> SELECT EXPAND( $c )
>>> LET $a = (select from (traverse * from (select in_language from Alias
>>> where name LUCENE 'fr_tord*') while $depth <=2) where @class='Location'
>>> order by name_en),
>>> $b = ( SELECT FROM Location where name_en LUCENE 'Minsk*' ),
>>> $c = UNIONALL( $a, $b )
>>>
>>> But the main question is still not answered. Is there any way to make
>>> similar search without traversing?
>>>
>>> вторник, 17 июня 2014 г., 13:22:00 UTC+3 пользователь Vladimir
>>> Ziankevich написал:
>>>
>>>> I have the next database schema:
>>>>
>>>> vertex type Location(properties: id, name)
>>>> vertex type Alias(properties: name)
>>>> edge type Language(properties: name)
>>>>
>>>> Each vertex of Location can have multiple edges with Aliases.
>>>> For example:
>>>> location(1,London) -> edge language(name='english') ->
>>>> alias(name='City of London')
>>>> -> edge
>>>> language(name='french') -> alias(name='Londres')
>>>>
>>>> There are about 600 000 locations and more than 1 000 000 aliases. I
>>>> need to implement fast search of locations through the location names and
>>>> aliases for typeahead.
>>>> I've applied Lucene indices both to Location.name and Alias.name and
>>>> expected to get appropriate locations list running query like:
>>>>
>>>> select from Location where name LUCENE 'Lon*' or out_language.in.name
>>>> LUCENE 'Lon*' limit=20
>>>> something like that.
>>>>
>>>> But it does not work. This query returns all the locations from
>>>> database.
>>>>
>>>> I've found another one query that works correctly
>>>>
>>>> select from
>>>> (traverse * from (select in_language from Alias where name LUCENE
>>>> 'Lon*') while $depth <=2)
>>>> where @class='Location'
>>>>
>>>> but I'm worried about the performance.
>>>>
>>>> Could someone offer me another variants? Or how to tune this one query.
>>>> Thanks in advance.
>>>>
>>> --
>>>
>>> ---
>>> 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/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] <javascript:>.
>> 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.