Skip to content

Commit 95d4750

Browse files
authored
[Remove] types from translog (#2439)
Removes persisting the type in the translog since types are no longer supported. Signed-off-by: Nicholas Walter Knize <[email protected]>
1 parent 6f12fa1 commit 95d4750

File tree

82 files changed

+334
-851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+334
-851
lines changed

modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,9 @@ private static Response prepareRamIndex(
593593
try (Directory directory = new ByteBuffersDirectory()) {
594594
try (IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(defaultAnalyzer))) {
595595
String index = indexService.index().getName();
596-
String type = indexService.mapperService().documentMapper().type();
597596
BytesReference document = request.contextSetup.document;
598597
XContentType xContentType = request.contextSetup.xContentType;
599-
SourceToParse sourceToParse = new SourceToParse(index, type, "_id", document, xContentType);
598+
SourceToParse sourceToParse = new SourceToParse(index, "_id", document, xContentType);
600599
ParsedDocument parsedDocument = indexService.mapperService().documentMapper().parse(sourceToParse);
601600
indexWriter.addDocuments(parsedDocument.docs());
602601
try (IndexReader indexReader = DirectoryReader.open(indexWriter)) {

modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void testDocumentParsingFailsOnMetaField() throws Exception {
9191
BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(rfMetaField, 0).endObject());
9292
MapperParsingException e = expectThrows(
9393
MapperParsingException.class,
94-
() -> mapper.parse(new SourceToParse("test", "_doc", "1", bytes, XContentType.JSON))
94+
() -> mapper.parse(new SourceToParse("test", "1", bytes, XContentType.JSON))
9595
);
9696
assertTrue(
9797
e.getCause().getMessage().contains("Field [" + rfMetaField + "] is a metadata field and cannot be added inside a document.")

modules/mapper-extras/src/test/java/org/opensearch/index/mapper/ScaledFloatFieldMapperTests.java

-9
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ public void testNotIndexed() throws Exception {
134134
ParsedDocument doc = mapper.parse(
135135
new SourceToParse(
136136
"test",
137-
"_doc",
138137
"1",
139138
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", 123).endObject()),
140139
XContentType.JSON
@@ -156,7 +155,6 @@ public void testNoDocValues() throws Exception {
156155
ParsedDocument doc = mapper.parse(
157156
new SourceToParse(
158157
"test",
159-
"_doc",
160158
"1",
161159
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", 123).endObject()),
162160
XContentType.JSON
@@ -178,7 +176,6 @@ public void testStore() throws Exception {
178176
ParsedDocument doc = mapper.parse(
179177
new SourceToParse(
180178
"test",
181-
"_doc",
182179
"1",
183180
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", 123).endObject()),
184181
XContentType.JSON
@@ -202,7 +199,6 @@ public void testCoerce() throws Exception {
202199
ParsedDocument doc = mapper.parse(
203200
new SourceToParse(
204201
"test",
205-
"_doc",
206202
"1",
207203
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "123").endObject()),
208204
XContentType.JSON
@@ -222,7 +218,6 @@ public void testCoerce() throws Exception {
222218
ThrowingRunnable runnable = () -> mapper2.parse(
223219
new SourceToParse(
224220
"test",
225-
"_doc",
226221
"1",
227222
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "123").endObject()),
228223
XContentType.JSON
@@ -246,7 +241,6 @@ private void doTestIgnoreMalformed(String value, String exceptionMessageContains
246241
ThrowingRunnable runnable = () -> mapper.parse(
247242
new SourceToParse(
248243
"test",
249-
"_doc",
250244
"1",
251245
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", value).endObject()),
252246
XContentType.JSON
@@ -261,7 +255,6 @@ private void doTestIgnoreMalformed(String value, String exceptionMessageContains
261255
ParsedDocument doc = mapper2.parse(
262256
new SourceToParse(
263257
"test",
264-
"_doc",
265258
"1",
266259
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", value).endObject()),
267260
XContentType.JSON
@@ -277,7 +270,6 @@ public void testNullValue() throws IOException {
277270
ParsedDocument doc = mapper.parse(
278271
new SourceToParse(
279272
"test",
280-
"_doc",
281273
"1",
282274
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField("field").endObject()),
283275
XContentType.JSON
@@ -291,7 +283,6 @@ public void testNullValue() throws IOException {
291283
doc = mapper.parse(
292284
new SourceToParse(
293285
"test",
294-
"_doc",
295286
"1",
296287
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField("field").endObject()),
297288
XContentType.JSON

modules/parent-join/src/test/java/org/opensearch/join/mapper/ParentJoinFieldMapperTests.java

+2-25
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,14 @@ public void testSingleLevel() throws Exception {
8080

8181
// Doc without join
8282
ParsedDocument doc = docMapper.parse(
83-
new SourceToParse(
84-
"test",
85-
"type",
86-
"0",
87-
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()),
88-
XContentType.JSON
89-
)
83+
new SourceToParse("test", "0", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), XContentType.JSON)
9084
);
9185
assertNull(doc.rootDoc().getBinaryValue("join_field"));
9286

9387
// Doc parent
9488
doc = docMapper.parse(
9589
new SourceToParse(
9690
"test",
97-
"type",
9891
"1",
9992
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "parent").endObject()),
10093
XContentType.JSON
@@ -107,7 +100,6 @@ public void testSingleLevel() throws Exception {
107100
doc = docMapper.parse(
108101
new SourceToParse(
109102
"test",
110-
"type",
111103
"2",
112104
BytesReference.bytes(
113105
XContentFactory.jsonBuilder()
@@ -131,7 +123,6 @@ public void testSingleLevel() throws Exception {
131123
() -> docMapper.parse(
132124
new SourceToParse(
133125
"test",
134-
"type",
135126
"1",
136127
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "unknown").endObject()),
137128
XContentType.JSON
@@ -161,7 +152,6 @@ public void testParentIdSpecifiedAsNumber() throws Exception {
161152
ParsedDocument doc = docMapper.parse(
162153
new SourceToParse(
163154
"test",
164-
"type",
165155
"2",
166156
BytesReference.bytes(
167157
XContentFactory.jsonBuilder()
@@ -181,7 +171,6 @@ public void testParentIdSpecifiedAsNumber() throws Exception {
181171
doc = docMapper.parse(
182172
new SourceToParse(
183173
"test",
184-
"type",
185174
"2",
186175
BytesReference.bytes(
187176
XContentFactory.jsonBuilder()
@@ -222,21 +211,14 @@ public void testMultipleLevels() throws Exception {
222211

223212
// Doc without join
224213
ParsedDocument doc = docMapper.parse(
225-
new SourceToParse(
226-
"test",
227-
"type",
228-
"0",
229-
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()),
230-
XContentType.JSON
231-
)
214+
new SourceToParse("test", "0", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), XContentType.JSON)
232215
);
233216
assertNull(doc.rootDoc().getBinaryValue("join_field"));
234217

235218
// Doc parent
236219
doc = docMapper.parse(
237220
new SourceToParse(
238221
"test",
239-
"type",
240222
"1",
241223
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "parent").endObject()),
242224
XContentType.JSON
@@ -249,7 +231,6 @@ public void testMultipleLevels() throws Exception {
249231
doc = docMapper.parse(
250232
new SourceToParse(
251233
"test",
252-
"type",
253234
"2",
254235
BytesReference.bytes(
255236
XContentFactory.jsonBuilder()
@@ -274,7 +255,6 @@ public void testMultipleLevels() throws Exception {
274255
() -> docMapper.parse(
275256
new SourceToParse(
276257
"test",
277-
"type",
278258
"2",
279259
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "child").endObject()),
280260
XContentType.JSON,
@@ -290,7 +270,6 @@ public void testMultipleLevels() throws Exception {
290270
() -> docMapper.parse(
291271
new SourceToParse(
292272
"test",
293-
"type",
294273
"2",
295274
BytesReference.bytes(
296275
XContentFactory.jsonBuilder()
@@ -311,7 +290,6 @@ public void testMultipleLevels() throws Exception {
311290
doc = docMapper.parse(
312291
new SourceToParse(
313292
"test",
314-
"type",
315293
"3",
316294
BytesReference.bytes(
317295
XContentFactory.jsonBuilder()
@@ -335,7 +313,6 @@ public void testMultipleLevels() throws Exception {
335313
() -> docMapper.parse(
336314
new SourceToParse(
337315
"test",
338-
"type",
339316
"1",
340317
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "unknown").endObject()),
341318
XContentType.JSON

modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
586586
}
587587
docMapper = mapperService.documentMapper();
588588
for (BytesReference document : documents) {
589-
docs.add(docMapper.parse(new SourceToParse(context.index().getName(), type, "_temp_id", document, documentXContentType)));
589+
docs.add(docMapper.parse(new SourceToParse(context.index().getName(), "_temp_id", document, documentXContentType)));
590590
}
591591

592592
FieldNameAnalyzer fieldNameAnalyzer = (FieldNameAnalyzer) docMapper.mappers().indexAnalyzer();

modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java

-17
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ public void testPercolatorFieldMapper() throws Exception {
553553
.parse(
554554
new SourceToParse(
555555
"test",
556-
MapperService.SINGLE_MAPPING_NAME,
557556
"1",
558557
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()),
559558
XContentType.JSON
@@ -574,7 +573,6 @@ public void testPercolatorFieldMapper() throws Exception {
574573
.parse(
575574
new SourceToParse(
576575
"test",
577-
MapperService.SINGLE_MAPPING_NAME,
578576
"1",
579577
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()),
580578
XContentType.JSON
@@ -592,7 +590,6 @@ public void testPercolatorFieldMapper() throws Exception {
592590
.parse(
593591
new SourceToParse(
594592
"test",
595-
MapperService.SINGLE_MAPPING_NAME,
596593
"1",
597594
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()),
598595
XContentType.JSON
@@ -621,7 +618,6 @@ public void testStoringQueries() throws Exception {
621618
.parse(
622619
new SourceToParse(
623620
"test",
624-
MapperService.SINGLE_MAPPING_NAME,
625621
"1",
626622
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, query).endObject()),
627623
XContentType.JSON
@@ -640,7 +636,6 @@ public void testQueryWithRewrite() throws Exception {
640636
.parse(
641637
new SourceToParse(
642638
"test",
643-
MapperService.SINGLE_MAPPING_NAME,
644639
"1",
645640
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()),
646641
XContentType.JSON
@@ -665,7 +660,6 @@ public void testPercolatorFieldMapperUnMappedField() throws Exception {
665660
.parse(
666661
new SourceToParse(
667662
"test",
668-
MapperService.SINGLE_MAPPING_NAME,
669663
"1",
670664
BytesReference.bytes(
671665
XContentFactory.jsonBuilder().startObject().field(fieldName, termQuery("unmapped_field", "value")).endObject()
@@ -684,7 +678,6 @@ public void testPercolatorFieldMapper_noQuery() throws Exception {
684678
.parse(
685679
new SourceToParse(
686680
"test",
687-
MapperService.SINGLE_MAPPING_NAME,
688681
"1",
689682
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()),
690683
XContentType.JSON
@@ -697,7 +690,6 @@ public void testPercolatorFieldMapper_noQuery() throws Exception {
697690
.parse(
698691
new SourceToParse(
699692
"test",
700-
MapperService.SINGLE_MAPPING_NAME,
701693
"1",
702694
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField(fieldName).endObject()),
703695
XContentType.JSON
@@ -760,7 +752,6 @@ public void testMultiplePercolatorFields() throws Exception {
760752
.parse(
761753
new SourceToParse(
762754
"test",
763-
typeName,
764755
"1",
765756
BytesReference.bytes(
766757
jsonBuilder().startObject().field("query_field1", queryBuilder).field("query_field2", queryBuilder).endObject()
@@ -803,7 +794,6 @@ public void testNestedPercolatorField() throws Exception {
803794
.parse(
804795
new SourceToParse(
805796
"test",
806-
typeName,
807797
"1",
808798
BytesReference.bytes(
809799
jsonBuilder().startObject().startObject("object_field").field("query_field", queryBuilder).endObject().endObject()
@@ -823,7 +813,6 @@ public void testNestedPercolatorField() throws Exception {
823813
.parse(
824814
new SourceToParse(
825815
"test",
826-
typeName,
827816
"1",
828817
BytesReference.bytes(
829818
jsonBuilder().startObject()
@@ -846,7 +835,6 @@ public void testNestedPercolatorField() throws Exception {
846835
.parse(
847836
new SourceToParse(
848837
"test",
849-
typeName,
850838
"1",
851839
BytesReference.bytes(
852840
jsonBuilder().startObject()
@@ -954,7 +942,6 @@ public void testImplicitlySetDefaultScriptLang() throws Exception {
954942
.parse(
955943
new SourceToParse(
956944
"test",
957-
MapperService.SINGLE_MAPPING_NAME,
958945
"1",
959946
BytesReference.bytes(
960947
XContentFactory.jsonBuilder()
@@ -1002,7 +989,6 @@ public void testImplicitlySetDefaultScriptLang() throws Exception {
1002989
.parse(
1003990
new SourceToParse(
1004991
"test",
1005-
MapperService.SINGLE_MAPPING_NAME,
1006992
"1",
1007993
BytesReference.bytes(
1008994
XContentFactory.jsonBuilder()
@@ -1097,7 +1083,6 @@ public void testDuplicatedClauses() throws Exception {
10971083
.parse(
10981084
new SourceToParse(
10991085
"test",
1100-
MapperService.SINGLE_MAPPING_NAME,
11011086
"1",
11021087
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, qb).endObject()),
11031088
XContentType.JSON
@@ -1123,7 +1108,6 @@ public void testDuplicatedClauses() throws Exception {
11231108
.parse(
11241109
new SourceToParse(
11251110
"test",
1126-
MapperService.SINGLE_MAPPING_NAME,
11271111
"1",
11281112
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, qb).endObject()),
11291113
XContentType.JSON
@@ -1152,7 +1136,6 @@ public void testDuplicatedClauses() throws Exception {
11521136
.parse(
11531137
new SourceToParse(
11541138
"test",
1155-
MapperService.SINGLE_MAPPING_NAME,
11561139
"1",
11571140
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, qb).endObject()),
11581141
XContentType.JSON

modules/reindex/src/internalClusterTest/java/org/opensearch/client/documentation/ReindexDocumentationIT.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,16 @@ public static class BlockingOperationListener implements IndexingOperationListen
342342

343343
@Override
344344
public Engine.Index preIndex(ShardId shardId, Engine.Index index) {
345-
return preCheck(index, index.type());
345+
return preCheck(index);
346346
}
347347

348348
@Override
349349
public Engine.Delete preDelete(ShardId shardId, Engine.Delete delete) {
350-
return preCheck(delete, delete.type());
350+
return preCheck(delete);
351351
}
352352

353-
private <T extends Engine.Operation> T preCheck(T operation, String type) {
354-
if (("_doc".equals(type) == false) || (operation.origin() != Engine.Operation.Origin.PRIMARY)) {
353+
private <T extends Engine.Operation> T preCheck(T operation) {
354+
if ((operation.origin() != Engine.Operation.Origin.PRIMARY)) {
355355
return operation;
356356
}
357357

0 commit comments

Comments
 (0)