[ https://issues.apache.org/jira/browse/SOLR-693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621980#action_12621980 ]
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 org.apache.solr.search.function like all the other ValueSource objects. > IntFieldSource incompatible with sint field type > ------------------------------------------------ > > Key: SOLR-693 > URL: https://issues.apache.org/jira/browse/SOLR-693 > 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 > org.apache.solr.search.function.IntFieldSource. Unfortunately, this throws > an exception when it executes: > HTTP ERROR: 500 > For input string: "€?" > java.lang.NumberFormatException: For input string: "€?" > at > java.lang.NumberFormatException.forInputString(NumberFormatException.java:61) > at java.lang.Integer.parseInt(Integer.java:460) > at java.lang.Integer.parseInt(Integer.java:510) > at > org.apache.lucene.search.FieldCacheImpl$3.parseInt(FieldCacheImpl.java:148) > at > org.apache.lucene.search.FieldCacheImpl$7.createValue(FieldCacheImpl.java:262) > at > org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:72) > at > org.apache.lucene.search.FieldCacheImpl.getInts(FieldCacheImpl.java:245) > at > org.apache.lucene.search.FieldCacheImpl.getInts(FieldCacheImpl.java:239) > at > org.apache.solr.search.function.IntFieldSource.getValues(IntFieldSource.java:50) > at > org.apache.solr.search.function.FunctionQuery$AllScorer.<init>(FunctionQuery.java:103) > at > org.apache.solr.search.function.FunctionQuery$FunctionWeight.scorer(FunctionQuery.java:81) > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:132) > at org.apache.lucene.search.Searcher.search(Searcher.java:126) > at org.apache.lucene.search.Searcher.search(Searcher.java:105) > at > org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:966) > at > org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:838) > at > org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:269) > at > org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:160) > at > org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:175) > at > org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135) > at org.apache.solr.core.SolrCore.execute(SolrCore.java:1151) > 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.