LUCENE-650: Fixed NPE in Locale specific String Sort when Document has no value

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@433049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2006-08-20 21:17:59 +00:00
parent d4cc53d466
commit 9763d03f48
3 changed files with 23 additions and 3 deletions

View File

@ -110,6 +110,10 @@ Bug fixes
13. LUCENE-659: Make PerFieldAnalyzerWrapper delegate getPositionIncrementGap()
to the correct analyzer for the field. (Chuck Williams via Yonik Seeley)
14. LUCENE-650: Fixed NPE in Locale specific String Sort when Document
has no value.
(Oliver Hutchison via Chris Hostetter)
Optimizations
1. LUCENE-586: TermDocs.skipTo() is now more efficient for multi-segment

View File

@ -316,9 +316,19 @@ extends PriorityQueue {
final String[] index = FieldCache.DEFAULT.getStrings (reader, field);
return new ScoreDocComparator() {
public final int compare (final ScoreDoc i, final ScoreDoc j) {
return collator.compare (index[i.doc], index[j.doc]);
}
public final int compare(final ScoreDoc i, final ScoreDoc j) {
String is = index[i.doc];
String js = index[j.doc];
if (is == js) {
return 0;
} else if (is == null) {
return -1;
} else if (js == null) {
return 1;
} else {
return collator.compare(is, js);
}
}
public Comparable sortValue (final ScoreDoc i) {
return index[i.doc];

View File

@ -261,6 +261,12 @@ implements Serializable {
sort.setSort ("string", true);
assertMatches (full, queryF, sort, "IJZ");
sort.setSort (new SortField ("i18n", Locale.ENGLISH));
assertMatches (full, queryF, sort, "ZJI");
sort.setSort (new SortField ("i18n", Locale.ENGLISH, true));
assertMatches (full, queryF, sort, "IJZ");
sort.setSort ("int");
assertMatches (full, queryF, sort, "IZJ");