Skip to content

Commit

Permalink
Remove type metadata from ingest documents (elastic#50131)
Browse files Browse the repository at this point in the history
Referring to the _type field in an Ingest document has been deprecated and effectively
a no-op since 7.x, and we can remove support for it entirely in 8.0

Relates to elastic#41059
  • Loading branch information
romseygeek authored and SivagurunathanV committed Jan 21, 2020
1 parent b4efe1f commit fb03630
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testConvertScalarToList() throws Exception {
public void testAppendMetadataExceptVersion() throws Exception {
// here any metadata field value becomes a list, which won't make sense in most of the cases,
// but support for append is streamlined like for set so we test it
MetaData randomMetaData = randomFrom(MetaData.INDEX, MetaData.TYPE, MetaData.ID, MetaData.ROUTING);
MetaData randomMetaData = randomFrom(MetaData.INDEX, MetaData.ID, MetaData.ROUTING);
List<String> values = new ArrayList<>();
Processor appendProcessor;
if (randomBoolean()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testSetExistingNullFieldWithOverrideDisabled() throws Exception {
}

public void testSetMetadataExceptVersion() throws Exception {
MetaData randomMetaData = randomFrom(MetaData.INDEX, MetaData.TYPE, MetaData.ID, MetaData.ROUTING);
MetaData randomMetaData = randomFrom(MetaData.INDEX, MetaData.ID, MetaData.ROUTING);
Processor processor = createSetProcessor(randomMetaData.getFieldName(), "_value", true);
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
processor.execute(ingestDocument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ private static List<IngestDocument> parseDocs(Map<String, Object> config) {
dataMap, Fields.SOURCE);
String index = ConfigurationUtils.readStringOrIntProperty(null, null,
dataMap, MetaData.INDEX.getFieldName(), "_index");
if (dataMap.containsKey(MetaData.TYPE.getFieldName())) {
deprecationLogger.deprecatedAndMaybeLog("simulate_pipeline_with_types",
"[types removal] specifying _type in pipeline simulation requests is deprecated");
}
String id = ConfigurationUtils.readStringOrIntProperty(null, null,
dataMap, MetaData.ID.getFieldName(), "_id");
String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.elasticsearch.index.mapper.IndexFieldMapper;
import org.elasticsearch.index.mapper.RoutingFieldMapper;
import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.mapper.TypeFieldMapper;
import org.elasticsearch.index.mapper.VersionFieldMapper;
import org.elasticsearch.script.TemplateScript;

Expand Down Expand Up @@ -692,7 +691,6 @@ public String toString() {

public enum MetaData {
INDEX(IndexFieldMapper.NAME),
TYPE(TypeFieldMapper.NAME),
ID(IdFieldMapper.NAME),
ROUTING(RoutingFieldMapper.NAME),
VERSION(VersionFieldMapper.NAME),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import static org.elasticsearch.ingest.IngestDocument.MetaData.ID;
import static org.elasticsearch.ingest.IngestDocument.MetaData.INDEX;
import static org.elasticsearch.ingest.IngestDocument.MetaData.ROUTING;
import static org.elasticsearch.ingest.IngestDocument.MetaData.TYPE;
import static org.elasticsearch.ingest.IngestDocument.MetaData.VERSION;
import static org.elasticsearch.ingest.IngestDocument.MetaData.VERSION_TYPE;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -109,15 +108,7 @@ public void testParseUsingPipelineStore() throws Exception {
assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(1));
}

public void testParseWithProvidedPipelineNoType() throws Exception {
innerTestParseWithProvidedPipeline(false);
}

public void testParseWithProvidedPipelineWithType() throws Exception {
innerTestParseWithProvidedPipeline(true);
}

private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws Exception {
public void innerTestParseWithProvidedPipeline() throws Exception {
int numDocs = randomIntBetween(1, 10);

Map<String, Object> requestContent = new HashMap<>();
Expand All @@ -127,7 +118,7 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws
for (int i = 0; i < numDocs; i++) {
Map<String, Object> doc = new HashMap<>();
Map<String, Object> expectedDoc = new HashMap<>();
List<IngestDocument.MetaData> fields = Arrays.asList(INDEX, TYPE, ID, ROUTING, VERSION, VERSION_TYPE);
List<IngestDocument.MetaData> fields = Arrays.asList(INDEX, ID, ROUTING, VERSION, VERSION_TYPE);
for(IngestDocument.MetaData field : fields) {
if (field == VERSION) {
Long value = randomLong();
Expand All @@ -139,14 +130,6 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws
);
doc.put(field.getFieldName(), value);
expectedDoc.put(field.getFieldName(), value);
} else if (field == TYPE) {
if (useExplicitType) {
String value = randomAlphaOfLengthBetween(1, 10);
doc.put(field.getFieldName(), value);
expectedDoc.put(field.getFieldName(), value);
} else {
expectedDoc.put(field.getFieldName(), "_doc");
}
} else {
if (randomBoolean()) {
String value = randomAlphaOfLengthBetween(1, 10);
Expand Down Expand Up @@ -213,9 +196,6 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws
assertThat(actualRequest.getPipeline().getId(), equalTo(SIMULATED_PIPELINE_ID));
assertThat(actualRequest.getPipeline().getDescription(), nullValue());
assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(numProcessors));
if (useExplicitType) {
assertWarnings("[types removal] specifying _type in pipeline simulation requests is deprecated");
}
}

public void testNullPipelineId() {
Expand Down

0 comments on commit fb03630

Please sign in to comment.