Skip to content

Commit 6531369

Browse files
authored
Don't persist type information to translog (#47229)
We no longer need to store type information in the translog, given that an index can only have a single type. Relates to #41059
1 parent 58ca9ee commit 6531369

File tree

100 files changed

+699
-858
lines changed

Some content is hidden

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

100 files changed

+699
-858
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,9 @@ private static Response prepareRamIndex(Request request,
544544
try (RAMDirectory ramDirectory = new RAMDirectory()) {
545545
try (IndexWriter indexWriter = new IndexWriter(ramDirectory, new IndexWriterConfig(defaultAnalyzer))) {
546546
String index = indexService.index().getName();
547-
String type = indexService.mapperService().documentMapper().type();
548547
BytesReference document = request.contextSetup.document;
549548
XContentType xContentType = request.contextSetup.xContentType;
550-
SourceToParse sourceToParse = new SourceToParse(index, type, "_id", document, xContentType);
549+
SourceToParse sourceToParse = new SourceToParse(index, "_id", document, xContentType);
551550
ParsedDocument parsedDocument = indexService.mapperService().documentMapper().parse(sourceToParse);
552551
indexWriter.addDocuments(parsedDocument.docs());
553552
try (IndexReader indexReader = DirectoryReader.open(indexWriter)) {

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeatureFieldMapperTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testDefaults() throws Exception {
7272

7373
assertEquals(mapping, mapper.mappingSource().toString());
7474

75-
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
75+
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "1", BytesReference
7676
.bytes(XContentFactory.jsonBuilder()
7777
.startObject()
7878
.field("field", 10)
@@ -84,7 +84,7 @@ public void testDefaults() throws Exception {
8484
assertThat(fields[0], Matchers.instanceOf(FeatureField.class));
8585
FeatureField featureField1 = (FeatureField) fields[0];
8686

87-
ParsedDocument doc2 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
87+
ParsedDocument doc2 = mapper.parse(new SourceToParse("test", "1", BytesReference
8888
.bytes(XContentFactory.jsonBuilder()
8989
.startObject()
9090
.field("field", 12)
@@ -108,7 +108,7 @@ public void testNegativeScoreImpact() throws Exception {
108108

109109
assertEquals(mapping, mapper.mappingSource().toString());
110110

111-
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
111+
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "1", BytesReference
112112
.bytes(XContentFactory.jsonBuilder()
113113
.startObject()
114114
.field("field", 10)
@@ -120,7 +120,7 @@ public void testNegativeScoreImpact() throws Exception {
120120
assertThat(fields[0], Matchers.instanceOf(FeatureField.class));
121121
FeatureField featureField1 = (FeatureField) fields[0];
122122

123-
ParsedDocument doc2 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
123+
ParsedDocument doc2 = mapper.parse(new SourceToParse("test", "1", BytesReference
124124
.bytes(XContentFactory.jsonBuilder()
125125
.startObject()
126126
.field("field", 12)
@@ -145,7 +145,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
145145
assertEquals(mapping, mapper.mappingSource().toString());
146146

147147
MapperParsingException e = expectThrows(MapperParsingException.class,
148-
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
148+
() -> mapper.parse(new SourceToParse("test", "1", BytesReference
149149
.bytes(XContentFactory.jsonBuilder()
150150
.startObject()
151151
.field("field", Arrays.asList(10, 20))
@@ -155,7 +155,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
155155
e.getCause().getMessage());
156156

157157
e = expectThrows(MapperParsingException.class,
158-
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
158+
() -> mapper.parse(new SourceToParse("test", "1", BytesReference
159159
.bytes(XContentFactory.jsonBuilder()
160160
.startObject()
161161
.startArray("foo")

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapperTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void testDefaults() throws Exception {
6161

6262
assertEquals(mapping, mapper.mappingSource().toString());
6363

64-
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
64+
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "1", BytesReference
6565
.bytes(XContentFactory.jsonBuilder()
6666
.startObject()
6767
.startObject("field")
@@ -95,7 +95,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
9595
assertEquals(mapping, mapper.mappingSource().toString());
9696

9797
MapperParsingException e = expectThrows(MapperParsingException.class,
98-
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
98+
() -> mapper.parse(new SourceToParse("test", "1", BytesReference
9999
.bytes(XContentFactory.jsonBuilder()
100100
.startObject()
101101
.startObject("field")
@@ -107,7 +107,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
107107
"START_ARRAY", e.getCause().getMessage());
108108

109109
e = expectThrows(MapperParsingException.class,
110-
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
110+
() -> mapper.parse(new SourceToParse("test", "1", BytesReference
111111
.bytes(XContentFactory.jsonBuilder()
112112
.startObject()
113113
.startArray("foo")

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testDefaults() throws Exception {
6565

6666
assertEquals(mapping, mapper.mappingSource().toString());
6767

68-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
68+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
6969
.bytes(XContentFactory.jsonBuilder()
7070
.startObject()
7171
.field("field", 123)
@@ -115,7 +115,7 @@ public void testNotIndexed() throws Exception {
115115

116116
assertEquals(mapping, mapper.mappingSource().toString());
117117

118-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
118+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
119119
.bytes(XContentFactory.jsonBuilder()
120120
.startObject()
121121
.field("field", 123)
@@ -139,7 +139,7 @@ public void testNoDocValues() throws Exception {
139139

140140
assertEquals(mapping, mapper.mappingSource().toString());
141141

142-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
142+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
143143
.bytes(XContentFactory.jsonBuilder()
144144
.startObject()
145145
.field("field", 123)
@@ -163,7 +163,7 @@ public void testStore() throws Exception {
163163

164164
assertEquals(mapping, mapper.mappingSource().toString());
165165

166-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
166+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
167167
.bytes(XContentFactory.jsonBuilder()
168168
.startObject()
169169
.field("field", 123)
@@ -192,7 +192,7 @@ public void testCoerce() throws Exception {
192192

193193
assertEquals(mapping, mapper.mappingSource().toString());
194194

195-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
195+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
196196
.bytes(XContentFactory.jsonBuilder()
197197
.startObject()
198198
.field("field", "123")
@@ -216,7 +216,7 @@ public void testCoerce() throws Exception {
216216

217217
assertEquals(mapping, mapper2.mappingSource().toString());
218218

219-
ThrowingRunnable runnable = () -> mapper2.parse(new SourceToParse("test", "type", "1", BytesReference
219+
ThrowingRunnable runnable = () -> mapper2.parse(new SourceToParse("test", "1", BytesReference
220220
.bytes(XContentFactory.jsonBuilder()
221221
.startObject()
222222
.field("field", "123")
@@ -245,7 +245,7 @@ private void doTestIgnoreMalformed(String value, String exceptionMessageContains
245245

246246
assertEquals(mapping, mapper.mappingSource().toString());
247247

248-
ThrowingRunnable runnable = () -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
248+
ThrowingRunnable runnable = () -> mapper.parse(new SourceToParse("test", "1", BytesReference
249249
.bytes(XContentFactory.jsonBuilder()
250250
.startObject()
251251
.field("field", value)
@@ -261,7 +261,7 @@ private void doTestIgnoreMalformed(String value, String exceptionMessageContains
261261

262262
DocumentMapper mapper2 = parser.parse("type", new CompressedXContent(mapping));
263263

264-
ParsedDocument doc = mapper2.parse(new SourceToParse("test", "type", "1", BytesReference
264+
ParsedDocument doc = mapper2.parse(new SourceToParse("test", "1", BytesReference
265265
.bytes(XContentFactory.jsonBuilder()
266266
.startObject()
267267
.field("field", value)
@@ -286,7 +286,7 @@ public void testNullValue() throws IOException {
286286
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
287287
assertEquals(mapping, mapper.mappingSource().toString());
288288

289-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
289+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
290290
.bytes(XContentFactory.jsonBuilder()
291291
.startObject()
292292
.nullField("field")
@@ -308,7 +308,7 @@ public void testNullValue() throws IOException {
308308
mapper = parser.parse("type", new CompressedXContent(mapping));
309309
assertEquals(mapping, mapper.mappingSource().toString());
310310

311-
doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
311+
doc = mapper.parse(new SourceToParse("test", "1", BytesReference
312312
.bytes(XContentFactory.jsonBuilder()
313313
.startObject()
314314
.nullField("field")

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapperTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void testIndexing() throws IOException {
101101
.mapperService()
102102
.documentMapperParser()
103103
.parse("_doc", new CompressedXContent(mapping));
104-
ParsedDocument doc = mapper.parse(new SourceToParse("test", "_doc", "1", BytesReference
104+
ParsedDocument doc = mapper.parse(new SourceToParse("test", "1", BytesReference
105105
.bytes(XContentFactory.jsonBuilder()
106106
.startObject()
107107
.field("a_field", "new york city")
@@ -273,7 +273,7 @@ public void testMultiFields() throws IOException {
273273
}
274274

275275
ParsedDocument doc = mapperService.documentMapper()
276-
.parse(new SourceToParse("test", "_doc", "1",
276+
.parse(new SourceToParse("test", "1",
277277
BytesReference.bytes(
278278
XContentFactory.jsonBuilder()
279279
.startObject()
@@ -740,7 +740,7 @@ private void documentParsingTestCase(Collection<String> values) throws IOExcepti
740740
}
741741
builder.endObject();
742742
final ParsedDocument parsedDocument = defaultMapper.parse(
743-
new SourceToParse("test", "_doc", "1", BytesReference.bytes(builder), XContentType.JSON));
743+
new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON));
744744

745745

746746
final Set<Matcher<IndexableField>> rootFieldMatchers = values.stream()

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/TokenCountFieldMapperTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private SourceToParse createDocument(String fieldValue) throws Exception {
192192
.field("test", fieldValue)
193193
.endObject());
194194

195-
return new SourceToParse("test", "person", "1", request, XContentType.JSON);
195+
return new SourceToParse("test", "1", request, XContentType.JSON);
196196
}
197197

198198
private ParseContext.Document parseDocument(DocumentMapper mapper, SourceToParse request) {

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ public void testSingleLevel() throws Exception {
6363
assertTrue(docMapper.mappers().getMapper("join_field") == ParentJoinFieldMapper.getMapper(service.mapperService()));
6464

6565
// Doc without join
66-
ParsedDocument doc = docMapper.parse(new SourceToParse("test", "type", "0",
66+
ParsedDocument doc = docMapper.parse(new SourceToParse("test", "0",
6767
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), XContentType.JSON));
6868
assertNull(doc.rootDoc().getBinaryValue("join_field"));
6969

7070
// Doc parent
71-
doc = docMapper.parse(new SourceToParse("test", "type", "1",
71+
doc = docMapper.parse(new SourceToParse("test", "1",
7272
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
7373
.field("join_field", "parent")
7474
.endObject()), XContentType.JSON));
7575
assertEquals("1", doc.rootDoc().getBinaryValue("join_field#parent").utf8ToString());
7676
assertEquals("parent", doc.rootDoc().getBinaryValue("join_field").utf8ToString());
7777

7878
// Doc child
79-
doc = docMapper.parse(new SourceToParse("test", "type", "2",
79+
doc = docMapper.parse(new SourceToParse("test", "2",
8080
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
8181
.startObject("join_field")
8282
.field("name", "child")
@@ -88,7 +88,7 @@ public void testSingleLevel() throws Exception {
8888

8989
// Unknown join name
9090
MapperException exc = expectThrows(MapperParsingException.class,
91-
() -> docMapper.parse(new SourceToParse("test", "type", "1",
91+
() -> docMapper.parse(new SourceToParse("test", "1",
9292
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
9393
.field("join_field", "unknown")
9494
.endObject()), XContentType.JSON)));
@@ -109,7 +109,7 @@ public void testParentIdSpecifiedAsNumber() throws Exception {
109109
IndexService service = createIndex("test");
110110
DocumentMapper docMapper = service.mapperService().merge("type", new CompressedXContent(mapping),
111111
MapperService.MergeReason.MAPPING_UPDATE);
112-
ParsedDocument doc = docMapper.parse(new SourceToParse("test", "type", "2",
112+
ParsedDocument doc = docMapper.parse(new SourceToParse("test", "2",
113113
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
114114
.startObject("join_field")
115115
.field("name", "child")
@@ -118,7 +118,7 @@ public void testParentIdSpecifiedAsNumber() throws Exception {
118118
.endObject()), XContentType.JSON, "1"));
119119
assertEquals("1", doc.rootDoc().getBinaryValue("join_field#parent").utf8ToString());
120120
assertEquals("child", doc.rootDoc().getBinaryValue("join_field").utf8ToString());
121-
doc = docMapper.parse(new SourceToParse("test", "type", "2",
121+
doc = docMapper.parse(new SourceToParse("test", "2",
122122
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
123123
.startObject("join_field")
124124
.field("name", "child")
@@ -147,12 +147,12 @@ public void testMultipleLevels() throws Exception {
147147
assertTrue(docMapper.mappers().getMapper("join_field") == ParentJoinFieldMapper.getMapper(service.mapperService()));
148148

149149
// Doc without join
150-
ParsedDocument doc = docMapper.parse(new SourceToParse("test", "type", "0",
150+
ParsedDocument doc = docMapper.parse(new SourceToParse("test", "0",
151151
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), XContentType.JSON));
152152
assertNull(doc.rootDoc().getBinaryValue("join_field"));
153153

154154
// Doc parent
155-
doc = docMapper.parse(new SourceToParse("test", "type", "1",
155+
doc = docMapper.parse(new SourceToParse("test", "1",
156156
BytesReference.bytes(XContentFactory.jsonBuilder()
157157
.startObject()
158158
.field("join_field", "parent")
@@ -161,7 +161,7 @@ public void testMultipleLevels() throws Exception {
161161
assertEquals("parent", doc.rootDoc().getBinaryValue("join_field").utf8ToString());
162162

163163
// Doc child
164-
doc = docMapper.parse(new SourceToParse("test", "type", "2",
164+
doc = docMapper.parse(new SourceToParse("test", "2",
165165
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
166166
.startObject("join_field")
167167
.field("name", "child")
@@ -174,15 +174,15 @@ public void testMultipleLevels() throws Exception {
174174

175175
// Doc child missing parent
176176
MapperException exc = expectThrows(MapperParsingException.class,
177-
() -> docMapper.parse(new SourceToParse("test", "type", "2",
177+
() -> docMapper.parse(new SourceToParse("test", "2",
178178
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
179179
.field("join_field", "child")
180180
.endObject()), XContentType.JSON, "1")));
181181
assertThat(exc.getRootCause().getMessage(), containsString("[parent] is missing for join field [join_field]"));
182182

183183
// Doc child missing routing
184184
exc = expectThrows(MapperParsingException.class,
185-
() -> docMapper.parse(new SourceToParse("test", "type", "2",
185+
() -> docMapper.parse(new SourceToParse("test", "2",
186186
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
187187
.startObject("join_field")
188188
.field("name", "child")
@@ -192,7 +192,7 @@ public void testMultipleLevels() throws Exception {
192192
assertThat(exc.getRootCause().getMessage(), containsString("[routing] is missing for join field [join_field]"));
193193

194194
// Doc grand_child
195-
doc = docMapper.parse(new SourceToParse("test", "type", "3",
195+
doc = docMapper.parse(new SourceToParse("test", "3",
196196
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
197197
.startObject("join_field")
198198
.field("name", "grand_child")
@@ -204,7 +204,7 @@ public void testMultipleLevels() throws Exception {
204204

205205
// Unknown join name
206206
exc = expectThrows(MapperParsingException.class,
207-
() -> docMapper.parse(new SourceToParse("test", "type", "1",
207+
() -> docMapper.parse(new SourceToParse("test", "1",
208208
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
209209
.field("join_field", "unknown")
210210
.endObject()), XContentType.JSON)));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
518518
String type = mapperService.documentMapper().type();
519519
docMapper = mapperService.documentMapper(type);
520520
for (BytesReference document : documents) {
521-
docs.add(docMapper.parse(new SourceToParse(context.index().getName(), type, "_temp_id", document, documentXContentType)));
521+
docs.add(docMapper.parse(new SourceToParse(context.index().getName(), "_temp_id", document, documentXContentType)));
522522
}
523523

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

0 commit comments

Comments
 (0)