Skip to content

Commit d68c2ad

Browse files
committed
Improve test a bit
1 parent 78eafbf commit d68c2ad

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

server/src/test/java/org/elasticsearch/index/codec/bloomfilter/ES93BloomFilterStoredFieldsFormatTests.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import org.apache.lucene.codecs.StoredFieldsFormat;
1515
import org.apache.lucene.document.Document;
1616
import org.apache.lucene.document.Field;
17-
import org.apache.lucene.document.FieldType;
18-
import org.apache.lucene.document.TextField;
17+
import org.apache.lucene.document.LongField;
18+
import org.apache.lucene.document.StringField;
1919
import org.apache.lucene.index.IndexWriter;
2020
import org.apache.lucene.index.IndexWriterConfig;
2121
import org.apache.lucene.index.LeafReader;
@@ -90,24 +90,15 @@ public void testBloomFilterFieldIsNotStoredAndBloomFilterCanBeChecked() throws I
9090
// We don't use the RandomIndexWriter because we want to control the settings so we get
9191
// deterministic test runs
9292
try (IndexWriter writer = new IndexWriter(directory, conf)) {
93-
FieldType customType = new FieldType(TextField.TYPE_STORED);
94-
customType.setTokenized(false);
95-
Field hostField = newField("host", "", customType);
96-
var fieldType = new FieldType();
97-
fieldType.setStored(true);
98-
fieldType.setTokenized(false);
99-
Field idField = newField(random(), IdFieldMapper.NAME, getBytesRefFromString(""), fieldType);
100-
10193
List<BytesRef> indexedIds = new ArrayList<>();
10294
var docCount = atLeast(50);
10395
for (int i = 0; i < docCount; i++) {
10496
Document doc = new Document();
105-
doc.add(idField);
10697
var id = getBytesRefFromString(UUIDs.randomBase64UUID());
10798
indexedIds.add(id);
108-
idField.setBytesValue(id);
109-
doc.add(hostField);
110-
hostField.setStringValue("host-" + i);
99+
doc.add(new StringField(IdFieldMapper.NAME, id, Field.Store.YES));
100+
doc.add(new StringField("host", "host-" + i, Field.Store.YES));
101+
doc.add(new LongField("counter", i, Field.Store.YES));
111102
writer.addDocument(doc);
112103
}
113104

@@ -139,6 +130,7 @@ public void testBloomFilterFieldIsNotStoredAndBloomFilterCanBeChecked() throws I
139130
// The _id field is not actually stored, just used to build the bloom filter
140131
assertThat(document.get(IdFieldMapper.NAME), nullValue());
141132
assertThat(document.get("host"), not(nullValue()));
133+
assertThat(document.get("counter"), not(nullValue()));
142134
}
143135
}
144136
}

0 commit comments

Comments
 (0)