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
|
@ -73,6 +73,10 @@ Bug fixes
|
||||||
without checking if the scorer is already at the right position.
|
without checking if the scorer is already at the right position.
|
||||||
scorer.skipTo(scorer.doc()) is not a NOOP, it behaves as
|
scorer.skipTo(scorer.doc()) is not a NOOP, it behaves as
|
||||||
scorer.next(). (Eks Dev, Michael Busch)
|
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
|
New features
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,15 @@ final class TermInfosWriter {
|
||||||
private int compareToLastTerm(int fieldNumber, char[] termText, int start, int length) {
|
private int compareToLastTerm(int fieldNumber, char[] termText, int start, int length) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
if (lastFieldNumber != fieldNumber)
|
if (lastFieldNumber != fieldNumber) {
|
||||||
return fieldInfos.fieldName(lastFieldNumber).compareTo(fieldInfos.fieldName(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) {
|
while(pos < length && pos < lastTermTextLength) {
|
||||||
final char c1 = lastTermText[pos];
|
final char c1 = lastTermText[pos];
|
||||||
|
|
|
@ -3113,4 +3113,14 @@ public class TestIndexWriter extends LuceneTestCase
|
||||||
ir.close();
|
ir.close();
|
||||||
dir.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