lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerry Quinn (JIRA)" <>
Subject [jira] Commented: (SOLR-693) IntFieldSource incompatible with sint field type
Date Tue, 12 Aug 2008 21:13:44 GMT


Jerry Quinn commented on SOLR-693:

I found SortableIntFieldSource but it's not publicly accessible.  It's also in org.apache.solr.schema
instead of like all the other ValueSource objects.

> IntFieldSource incompatible with sint field type
> ------------------------------------------------
>                 Key: SOLR-693
>                 URL:
>             Project: Solr
>          Issue Type: Bug
>          Components: search
>    Affects Versions: 1.3
>         Environment: RHEL 5, java6, builtin jetty container
>            Reporter: Jerry Quinn
> I'm trying to create a custom scoring query in Solr to implement a date bias.  I have
a custom query parser that I'm using, that does nothing but wrap a BoostedQuery around the
original query, which works in general.
> I'm indexing and storing the day number in an sint field.  To implement my query, I extract
the contents using  Unfortunately, this throws
an exception when it executes:
> For input string: "€?"
> java.lang.NumberFormatException: For input string: "€?"
> 	at java.lang.NumberFormatException.forInputString(
> 	at java.lang.Integer.parseInt(
> 	at java.lang.Integer.parseInt(
> 	at$3.parseInt(
> 	at$7.createValue(
> 	at$Cache.get(
> 	at
> 	at
> 	at
> 	at$AllScorer.<init>(
> 	at$FunctionWeight.scorer(
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at org.apache.solr.handler.component.QueryComponent.process(
> 	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(
> 	at org.apache.solr.handler.RequestHandlerBase.handleRequest(
> 	at org.apache.solr.core.SolrCore.execute(
> I ran into exactly the same problem when I tried to use the CustomScoreQuery and IntFieldSource
classes from Lucene.
> I've tracked the problem down to the fact that IntFieldSource expects the contents of
the field to actually be an integer as returned by FieldCache.getInts().  However, Solr converts
a sortable int using NumberUtils.int2sortablestr().
> If I change my code to create a custom FieldCache.IntParser that applies NumberUtils.SortableStr2int
before returning the value, my query works as expected.  For example:
> class MyIntParser implements FieldCache.IntParser {
>   public int parseInt(String val) { return NumberUtils.SortedStr2int(val, 0, val.length());
> }
> Query q = new BoostedQuery(qry, new IntFieldSource("myfield", new MyIntParser()));

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message