Skip to content

Commit 9ec1b11

Browse files
committed
term vectors: The term vector APIs no longer modify the mappings if an unmapped field is found
1 parent e3816d5 commit 9ec1b11

File tree

3 files changed

+7
-55
lines changed

3 files changed

+7
-55
lines changed

core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@
7171

7272
public class TermVectorsService {
7373

74-
private final MappingUpdatedAction mappingUpdatedAction;
7574
private final TransportDfsOnlyAction dfsAction;
7675

7776
@Inject
78-
public TermVectorsService(MappingUpdatedAction mappingUpdatedAction, TransportDfsOnlyAction dfsAction) {
79-
this.mappingUpdatedAction = mappingUpdatedAction;
77+
public TermVectorsService(TransportDfsOnlyAction dfsAction) {
8078
this.dfsAction = dfsAction;
8179
}
8280

@@ -293,16 +291,11 @@ private Fields generateTermVectorsFromDoc(IndexShard indexShard, TermVectorsRequ
293291

294292
private ParsedDocument parseDocument(IndexShard indexShard, String index, String type, BytesReference doc) throws Throwable {
295293
MapperService mapperService = indexShard.mapperService();
296-
297-
// TODO: make parsing not dynamically create fields not in the original mapping
298294
DocumentMapperForType docMapper = mapperService.documentMapperWithAutoCreate(type);
299295
ParsedDocument parsedDocument = docMapper.getDocumentMapper().parse(source(doc).index(index).type(type).flyweight(true));
300296
if (docMapper.getMapping() != null) {
301297
parsedDocument.addDynamicMappingsUpdate(docMapper.getMapping());
302298
}
303-
if (parsedDocument.dynamicMappingsUpdate() != null) {
304-
mappingUpdatedAction.updateMappingOnMasterSynchronously(index, type, parsedDocument.dynamicMappingsUpdate());
305-
}
306299
return parsedDocument;
307300
}
308301

core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -870,53 +870,6 @@ public void testArtificialNoDoc() throws IOException {
870870
checkBrownFoxTermVector(resp.getFields(), "field1", false);
871871
}
872872

873-
public void testArtificialNonExistingField() throws Exception {
874-
// setup indices
875-
Settings.Builder settings = settingsBuilder()
876-
.put(indexSettings())
877-
.put("index.analysis.analyzer", "standard");
878-
assertAcked(prepareCreate("test")
879-
.setSettings(settings)
880-
.addMapping("type1", "field1", "type=string"));
881-
ensureGreen();
882-
883-
// index just one doc
884-
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
885-
indexBuilders.add(client().prepareIndex()
886-
.setIndex("test")
887-
.setType("type1")
888-
.setId("1")
889-
.setRouting("1")
890-
.setSource("field1", "some text"));
891-
indexRandom(true, indexBuilders);
892-
893-
// request tvs from artificial document
894-
XContentBuilder doc = jsonBuilder()
895-
.startObject()
896-
.field("field1", "the quick brown fox jumps over the lazy dog")
897-
.field("non_existing", "the quick brown fox jumps over the lazy dog")
898-
.endObject();
899-
900-
for (int i = 0; i < 2; i++) {
901-
TermVectorsResponse resp = client().prepareTermVectors()
902-
.setIndex("test")
903-
.setType("type1")
904-
.setDoc(doc)
905-
.setRouting("" + i)
906-
.setOffsets(true)
907-
.setPositions(true)
908-
.setFieldStatistics(true)
909-
.setTermStatistics(true)
910-
.get();
911-
assertThat(resp.isExists(), equalTo(true));
912-
checkBrownFoxTermVector(resp.getFields(), "field1", false);
913-
// we should have created a mapping for this field
914-
assertMappingOnMaster("test", "type1", "non_existing");
915-
// and return the generated term vectors
916-
checkBrownFoxTermVector(resp.getFields(), "non_existing", false);
917-
}
918-
}
919-
920873
public void testPerFieldAnalyzer() throws IOException {
921874
int numFields = 25;
922875

docs/reference/migration/migrate_3_0.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ your application to Elasticsearch 3.0.
1818
* <<breaking_30_percolator>>
1919
* <<breaking_30_packaging>>
2020
* <<breaking_30_scripting>>
21+
* <<breaking_30_term_vectors>>
2122

2223
[[breaking_30_search_changes]]
2324
=== Warmers
@@ -707,3 +708,8 @@ Previously script mode settings (e.g., "script.inline: true",
707708
values `off`, `false`, `0`, and `no` for disabling a scripting mode.
708709
The variants `on`, `1`, and `yes ` for enabling and `off`, `0`,
709710
and `no` for disabling are no longer supported.
711+
712+
[[breaking_30_term_vectors]]
713+
=== Term vectors
714+
715+
The term vectors APIs no longer persist unmapped fields in the mappings.

0 commit comments

Comments
 (0)