From 9ec1b11148fe2a347c31f64d6630a42fffbef763 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 28 Jan 2016 10:31:43 +0100 Subject: [PATCH] term vectors: The term vector APIs no longer modify the mappings if an unmapped field is found --- .../index/termvectors/TermVectorsService.java | 9 +--- .../action/termvectors/GetTermVectorsIT.java | 47 ------------------- docs/reference/migration/migrate_3_0.asciidoc | 6 +++ 3 files changed, 7 insertions(+), 55 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java b/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java index fbc18fd578a..c78d125ab46 100644 --- a/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java +++ b/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java @@ -71,12 +71,10 @@ import static org.elasticsearch.index.mapper.SourceToParse.source; public class TermVectorsService { - private final MappingUpdatedAction mappingUpdatedAction; private final TransportDfsOnlyAction dfsAction; @Inject - public TermVectorsService(MappingUpdatedAction mappingUpdatedAction, TransportDfsOnlyAction dfsAction) { - this.mappingUpdatedAction = mappingUpdatedAction; + public TermVectorsService(TransportDfsOnlyAction dfsAction) { this.dfsAction = dfsAction; } @@ -293,16 +291,11 @@ public class TermVectorsService { private ParsedDocument parseDocument(IndexShard indexShard, String index, String type, BytesReference doc) throws Throwable { MapperService mapperService = indexShard.mapperService(); - - // TODO: make parsing not dynamically create fields not in the original mapping DocumentMapperForType docMapper = mapperService.documentMapperWithAutoCreate(type); ParsedDocument parsedDocument = docMapper.getDocumentMapper().parse(source(doc).index(index).type(type).flyweight(true)); if (docMapper.getMapping() != null) { parsedDocument.addDynamicMappingsUpdate(docMapper.getMapping()); } - if (parsedDocument.dynamicMappingsUpdate() != null) { - mappingUpdatedAction.updateMappingOnMasterSynchronously(index, type, parsedDocument.dynamicMappingsUpdate()); - } return parsedDocument; } diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java index 16fd9f4b718..45b045a7f4b 100644 --- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java +++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java @@ -870,53 +870,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { checkBrownFoxTermVector(resp.getFields(), "field1", false); } - public void testArtificialNonExistingField() throws Exception { - // setup indices - Settings.Builder settings = settingsBuilder() - .put(indexSettings()) - .put("index.analysis.analyzer", "standard"); - assertAcked(prepareCreate("test") - .setSettings(settings) - .addMapping("type1", "field1", "type=string")); - ensureGreen(); - - // index just one doc - List indexBuilders = new ArrayList<>(); - indexBuilders.add(client().prepareIndex() - .setIndex("test") - .setType("type1") - .setId("1") - .setRouting("1") - .setSource("field1", "some text")); - indexRandom(true, indexBuilders); - - // request tvs from artificial document - XContentBuilder doc = jsonBuilder() - .startObject() - .field("field1", "the quick brown fox jumps over the lazy dog") - .field("non_existing", "the quick brown fox jumps over the lazy dog") - .endObject(); - - for (int i = 0; i < 2; i++) { - TermVectorsResponse resp = client().prepareTermVectors() - .setIndex("test") - .setType("type1") - .setDoc(doc) - .setRouting("" + i) - .setOffsets(true) - .setPositions(true) - .setFieldStatistics(true) - .setTermStatistics(true) - .get(); - assertThat(resp.isExists(), equalTo(true)); - checkBrownFoxTermVector(resp.getFields(), "field1", false); - // we should have created a mapping for this field - assertMappingOnMaster("test", "type1", "non_existing"); - // and return the generated term vectors - checkBrownFoxTermVector(resp.getFields(), "non_existing", false); - } - } - public void testPerFieldAnalyzer() throws IOException { int numFields = 25; diff --git a/docs/reference/migration/migrate_3_0.asciidoc b/docs/reference/migration/migrate_3_0.asciidoc index 067932ca21f..78f8ff40307 100644 --- a/docs/reference/migration/migrate_3_0.asciidoc +++ b/docs/reference/migration/migrate_3_0.asciidoc @@ -18,6 +18,7 @@ your application to Elasticsearch 3.0. * <> * <> * <> +* <> [[breaking_30_search_changes]] === Warmers @@ -707,3 +708,8 @@ Previously script mode settings (e.g., "script.inline: true", values `off`, `false`, `0`, and `no` for disabling a scripting mode. The variants `on`, `1`, and `yes ` for enabling and `off`, `0`, and `no` for disabling are no longer supported. + +[[breaking_30_term_vectors]] +=== Term vectors + +The term vectors APIs no longer persist unmapped fields in the mappings.