mirror of https://github.com/apache/lucene.git
LUCENE-1179: allow Fields with empty string field names
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@628080 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9f2e3cf7bc
commit
cc64e6fdde
|
@ -74,6 +74,10 @@ Bug fixes
|
|||
scorer.skipTo(scorer.doc()) is not a NOOP, it behaves as
|
||||
scorer.next(). (Eks Dev, Michael Busch)
|
||||
|
||||
5. LUCENE-1179: Fixed assert statement that was incorrectly
|
||||
preventing Fields with empty-string field name from working.
|
||||
(Sergey Kabashnyuk via Mike McCandless)
|
||||
|
||||
New features
|
||||
|
||||
1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis
|
||||
|
|
|
@ -111,8 +111,15 @@ final class TermInfosWriter {
|
|||
private int compareToLastTerm(int fieldNumber, char[] termText, int start, int length) {
|
||||
int pos = 0;
|
||||
|
||||
if (lastFieldNumber != fieldNumber)
|
||||
return fieldInfos.fieldName(lastFieldNumber).compareTo(fieldInfos.fieldName(fieldNumber));
|
||||
if (lastFieldNumber != fieldNumber) {
|
||||
final int cmp = fieldInfos.fieldName(lastFieldNumber).compareTo(fieldInfos.fieldName(fieldNumber));
|
||||
// If there is a field named "" (empty string) then we
|
||||
// will get 0 on this comparison, yet, it's "OK". But
|
||||
// it's not OK if two different field numbers map to
|
||||
// the same name.
|
||||
if (cmp != 0 || lastFieldNumber != -1)
|
||||
return cmp;
|
||||
}
|
||||
|
||||
while(pos < length && pos < lastTermTextLength) {
|
||||
final char c1 = lastTermText[pos];
|
||||
|
|
|
@ -3113,4 +3113,14 @@ public class TestIndexWriter extends LuceneTestCase
|
|||
ir.close();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
// LUCENE-1179
|
||||
public void testEmptyFieldName() throws IOException {
|
||||
MockRAMDirectory dir = new MockRAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer());
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("", "a b c", Field.Store.NO, Field.Index.TOKENIZED));
|
||||
writer.addDocument(doc);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue