|
14 | 14 | import org.apache.lucene.codecs.StoredFieldsFormat; |
15 | 15 | import org.apache.lucene.document.Document; |
16 | 16 | 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; |
19 | 19 | import org.apache.lucene.index.IndexWriter; |
20 | 20 | import org.apache.lucene.index.IndexWriterConfig; |
21 | 21 | import org.apache.lucene.index.LeafReader; |
@@ -90,24 +90,15 @@ public void testBloomFilterFieldIsNotStoredAndBloomFilterCanBeChecked() throws I |
90 | 90 | // We don't use the RandomIndexWriter because we want to control the settings so we get |
91 | 91 | // deterministic test runs |
92 | 92 | 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 | | - |
101 | 93 | List<BytesRef> indexedIds = new ArrayList<>(); |
102 | 94 | var docCount = atLeast(50); |
103 | 95 | for (int i = 0; i < docCount; i++) { |
104 | 96 | Document doc = new Document(); |
105 | | - doc.add(idField); |
106 | 97 | var id = getBytesRefFromString(UUIDs.randomBase64UUID()); |
107 | 98 | 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)); |
111 | 102 | writer.addDocument(doc); |
112 | 103 | } |
113 | 104 |
|
@@ -139,6 +130,7 @@ public void testBloomFilterFieldIsNotStoredAndBloomFilterCanBeChecked() throws I |
139 | 130 | // The _id field is not actually stored, just used to build the bloom filter |
140 | 131 | assertThat(document.get(IdFieldMapper.NAME), nullValue()); |
141 | 132 | assertThat(document.get("host"), not(nullValue())); |
| 133 | + assertThat(document.get("counter"), not(nullValue())); |
142 | 134 | } |
143 | 135 | } |
144 | 136 | } |
|
0 commit comments