You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Zhang, Lisheng" <Li...@BroadVision.com> on 2013/04/08 21:28:40 UTC

Solr language-dependent sort

Hi,

I found that in solr we need to define a special fieldType for each
language (http://wiki.apache.org/solr/UnicodeCollation), then point
a field to this type.

But in our application one field (like 'title') can be used by various
users for their languages (user1 used for English, user2 used it for
Japanese ..), so it is even difficult for us to use dynamical field,
we would prefer to pass in a parameter like 

language = 'en'

at run time, then solr API may use this parameter to call lucene API
to sort a field. This approach would be much more flexible (we programmed
this way when using lucene directly)?

Thanks very much for helps, Lisheng

RE: Solr language-dependent sort

Posted by "Zhang, Lisheng" <Li...@BroadVision.com>.
Hi,

Thanks very much for quick help!

In our case we mainly need to sort a field based on language defined at run time,
but I understood that the principle is the same.

Thanks and best regards, Lisheng

-----Original Message-----
From: Sujit Pal [mailto:sujitatgtalk@gmail.com]On Behalf Of SUJIT PAL
Sent: Monday, April 08, 2013 1:27 PM
To: solr-user@lucene.apache.org
Subject: Re: Solr language-dependent sort


Hi Lisheng,

We did something similar in Solr using a custom handler (but I think you could just build a custom QeryParser to do this), but you could do this in your application as well, ie, get the language and then rewrite your query to use the language specific fields. Come to think of it, the QueryParser would probably be sufficiently general to qualify as a patch for custom functionality.

-sujit

On Apr 8, 2013, at 12:28 PM, Zhang, Lisheng wrote:

> 
> Hi,
> 
> I found that in solr we need to define a special fieldType for each
> language (http://wiki.apache.org/solr/UnicodeCollation), then point
> a field to this type.
> 
> But in our application one field (like 'title') can be used by various
> users for their languages (user1 used for English, user2 used it for
> Japanese ..), so it is even difficult for us to use dynamical field,
> we would prefer to pass in a parameter like 
> 
> language = 'en'
> 
> at run time, then solr API may use this parameter to call lucene API
> to sort a field. This approach would be much more flexible (we programmed
> this way when using lucene directly)?
> 
> Thanks very much for helps, Lisheng


Re: Solr language-dependent sort

Posted by SUJIT PAL <su...@comcast.net>.
Hi Lisheng,

We did something similar in Solr using a custom handler (but I think you could just build a custom QeryParser to do this), but you could do this in your application as well, ie, get the language and then rewrite your query to use the language specific fields. Come to think of it, the QueryParser would probably be sufficiently general to qualify as a patch for custom functionality.

-sujit

On Apr 8, 2013, at 12:28 PM, Zhang, Lisheng wrote:

> 
> Hi,
> 
> I found that in solr we need to define a special fieldType for each
> language (http://wiki.apache.org/solr/UnicodeCollation), then point
> a field to this type.
> 
> But in our application one field (like 'title') can be used by various
> users for their languages (user1 used for English, user2 used it for
> Japanese ..), so it is even difficult for us to use dynamical field,
> we would prefer to pass in a parameter like 
> 
> language = 'en'
> 
> at run time, then solr API may use this parameter to call lucene API
> to sort a field. This approach would be much more flexible (we programmed
> this way when using lucene directly)?
> 
> Thanks very much for helps, Lisheng