Re: [Tracker] question of tracker sparql query multi langauge order



Hey,

On mar, 2013-05-28 at 13:55 +0100, Martyn Russell wrote:
On 22/05/13 16:45, Eugene Seo wrote:
Dear all,

Hello Eugene,

I have a question of tracker sparql query order with multi langauges.
Currently tracker supports Sparql  1.0 and sorts the result in unicode
order, as I know.

Yes it does.

Is it possible to sort other language prior to English?

Usually sorting by different languages is done by the locale 
settings/environment. Sorting by language per query isn't currently 
possible because we build collations based on the language being used. 
If you change language, we rebuild those collations in the database.

In SQLite, specific chacracters can be sorted in front with following
syntax,
ORDER BY (CASE WHEN str between '0' and '9' THEN 1 WHEN str between 'a'
and 'z' THEN 2 ELSE 3 END)

This is pretty cool and I didn't know about this I have to say.

I'm wondering though, doesn't this kill ordering between items of the
same group? If everything from A to Z is 2, the ordering would be
arbitrary there AFAICS.


I wonder there is similar syntax of SPARQL query like CASE WHEN THEN of
SQLITE.

Well, the SPARQL in Tracker is interpreted, some of it (like ORDER BY) 
is used directly for the SQL used in SQLite. I haven't actually tried 
the example you suggest above, have you? I am curious to know if you 
tested this yet? :)

If there is any way to sort other langague first than English, please
share with me.

What's interesting here is, that we use libicu or libunistring for the 
collation/sorting. Whether this works or not depends on a few things:

1. We need to fix our parser to allow the CASE/WHEN/END system. A quick 
test here shows we don't allow that right now.

2. I don't actually know how SQLite would treat such a query on a 
collated column, we would need to figure this part out.

If those two steps work, Tracker should support it.

As precisely we have the collator taking care of sorting, I think
something like this should be implemented there, using CASE/THEN/END or
sqlite functions sound like ways to impersonate it.

An easy way to do this is to assign fixed weights to char ranges and
add/subtract to the collation return value before returning. Knowing
which locales might benefit of that could be more tricky... or maybe we
should just add a gsetting.

 Carlos


--

Can I ask how you're using tracker to understand why you need to sort 
for different languages by query?

Thanks,

-- 
Regards,
Martyn

Founder and CEO of Lanedo GmbH.
_______________________________________________
tracker-list mailing list
tracker-list gnome org
https://mail.gnome.org/mailman/listinfo/tracker-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]