Converting SortableIntField to Integer (Externalizing)

View: New views
4 Messages — Rating Filter:   Alert me  

Converting SortableIntField to Integer (Externalizing)

by Chantal Ackermann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

has anyone some code snippet on how to convert the String representation
of a SortableIntField (or SortableLongField or else) to a
java.lang.Integer or int?

Input: String (cryptic, non human readable, value of a sint field)
Output: Integer or int

I would appreciate if anyone could give me some hint/pointer/input on
how to do that. I couldn't find anything about it in the Javadoc for
SortableIntField or by googling for it.



More in detail:
Requesting for example "interestingTerms" using the MoreLikeThisHandler
returns a list of fields and terms where the terms' string values are
not externalized. Thus, fields of type sint do not contain the actual
int value but some cryptic (non-human-readable) string. I would like to
extract the int value to create another query with it.


Thanks a lot,
Chantal

Re: Converting SortableIntField to Integer (Externalizing)

by Yonik Seeley-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 10, 2009 at 10:26 AM, Chantal Ackermann
<chantal.ackermann@...> wrote:
> has anyone some code snippet on how to convert the String representation of
> a SortableIntField (or SortableLongField or else) to a java.lang.Integer or
> int?

FieldType.indexedToReadable()

-Yonik
http://www.lucidimagination.com

Re: Converting SortableIntField to Integer (Externalizing)

by Chantal Ackermann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Yonik,

this works fine for me! However, I'm using Java/SolrJ and I have the
freedom to add any necessary jars to convert the value.

But how about clients that cannot make use of FieldType? They cannot use
those custom values and will be stuck at that point, isn't it?

Shall I still open a JIRA issue on that?

Cheers,
Chantal

Yonik Seeley schrieb:

> On Tue, Nov 10, 2009 at 10:26 AM, Chantal Ackermann
> <chantal.ackermann@...> wrote:
>> has anyone some code snippet on how to convert the String representation of
>> a SortableIntField (or SortableLongField or else) to a java.lang.Integer or
>> int?
>
> FieldType.indexedToReadable()
>
> -Yonik
> http://www.lucidimagination.com

Re: Converting SortableIntField to Integer (Externalizing)

by Yonik Seeley-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Nov 12, 2009 at 8:02 AM, Chantal Ackermann
<chantal.ackermann@...> wrote:
> this works fine for me! However, I'm using Java/SolrJ and I have the freedom
> to add any necessary jars to convert the value.

These conversions should normally be done on the Solr server side
(i.e. MoreLikeThis component needs a patch), not the client side.

-Yonik
http://www.lucidimagination.com