Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@

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;
}

Expand Down Expand Up @@ -293,16 +291,11 @@ private Fields generateTermVectorsFromDoc(IndexShard indexShard, TermVectorsRequ

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,53 +870,6 @@ public void testArtificialNoDoc() throws IOException {
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<IndexRequestBuilder> 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;

Expand Down
6 changes: 6 additions & 0 deletions docs/reference/migration/migrate_3_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ your application to Elasticsearch 3.0.
* <<breaking_30_percolator>>
* <<breaking_30_packaging>>
* <<breaking_30_scripting>>
* <<breaking_30_term_vectors>>

[[breaking_30_search_changes]]
=== Warmers
Expand Down Expand Up @@ -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.