Thx Uwe,

after sleeping over the problem...
The solution just hit me ;)
I index a double for the Numeric field but my Sortfield was setup as a float.
(Maybe this is something for a FAQ for NumericFields)

Thx

Uwe

-----Ursprüngliche Nachricht-----
Von: Uwe Schindler [mailto:u...@thetaphi.de] 
Gesendet: Dienstag, 26. Oktober 2010 09:30
An: java-user@lucene.apache.org
Betreff: RE: Problem with sorting on NumericFields

This happens if your field still contains other value types in this field,
maybe from deleted documents. The problem is that even if no document
contains the old field encoding anymore, it could still be leftover terms in
terms index. So the FieldCache code loads the terms (even if no longer
documents are attached) and  tries to parse it. So if it was before a
different field type like a conventional plain text encoded numeric, the
parsing of those old terms fails. You should reindex the whole stuff or at
least try to optimize the index to get rid of deleted documents and the
terms.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de


> -----Original Message-----
> From: Uwe Goetzke [mailto:uwe.goet...@veenion.de]
> Sent: Monday, October 25, 2010 9:43 PM
> To: java-user@lucene.apache.org
> Subject: Problem with sorting on NumericFields
> 
> I got stuck on a problem using  NumericFields using with lucene 2.9.3
> 
> 
> 
> I add values  to the document by
> 
> doc.add(new NumericField("minprice").setDoubleValue(net_price));
> 
> 
> 
> If I want to search with a sorter for this field, I get this error:
> 
> 
> 
> java.lang.NumberFormatException: Invalid shift value in prefixCoded string
(is
> encoded value really an INT?)
> 
>                 at
> org.apache.lucene.util.NumericUtils.prefixCodedToInt(NumericUtils.java:2
> 33)
> 
>                 at
> org.apache.lucene.search.FieldCache$8.parseFloat(FieldCache.java:256)
> 
>                 at
> org.apache.lucene.search.FieldCacheImpl$FloatCache.createValue(FieldCach
> eImpl.java:514)
> 
>                 at
> org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:22
> 4)
> 
>                 at
> org.apache.lucene.search.FieldCacheImpl.getFloats(FieldCacheImpl.java:48
> 7)
> 
>                 at
> org.apache.lucene.search.FieldCacheImpl$FloatCache.createValue(FieldCach
> eImpl.java:504)
> 
>                 at
> org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:22
> 4)
> 
>                 at
> org.apache.lucene.search.FieldCacheImpl.getFloats(FieldCacheImpl.java:48
> 7)
> 
>                 at
> org.apache.lucene.search.FieldComparator$FloatComparator.setNextReader(F
> ieldComparator.java:269)
> 
>                 at
> org.apache.lucene.search.TopFieldCollector$MultiComparatorNonScoringColl
> ector.setNextReader(TopFieldCollector.java:435)
> 
>                 at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:257)
> 
>                 at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:240)
> 
>                 at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:181)
> 
>                 at
> org.apache.lucene.search.Searcher.search(Searcher.java:90)
> 
> 
> 
> The Sort field as seen by the debugger:
> 
> *     sort_fields = {org.apache.lucene.search.sortfield...@9010}
> *     [0] = {org.apache.lucene.search.sortfi...@9011}"!"
> *     field = {java.lang.str...@8642}"minprice"
> *     type = 5
> *     locale = null
> *     reverse = true
> *     factory = null
> *     parser = null
> *     comparatorSource = null
> *     useLegacy = false
> 
> I run out of ideas what might go wrong. I did look at the index with luke
and I
> do not see anything special.
> 
> As this happens with the same code on other servers, too, It looks like
some
> kind of programming error.
> 
> Any hints?
> 
> Thx
> 
> 
> 
> Uwe
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to