avoid stripping out _source prefix when in _ingest context

This commit is contained in:
javanna 2015-12-09 18:42:20 +01:00 committed by Luca Cavanna
parent 57d6971252
commit a95f81c015
2 changed files with 11 additions and 5 deletions

View File

@ -467,12 +467,12 @@ public final class IngestDocument {
newPath = path.substring(8, path.length());
} else {
initialContext = sourceAndMetadata;
if (path.startsWith("_source.")) {
newPath = path.substring(8, path.length());
} else {
newPath = path;
}
if (newPath.startsWith("_source.")) {
newPath = newPath.substring(8, path.length());
}
this.pathElements = Strings.splitStringToArray(newPath, '.');
if (pathElements.length == 0) {
throw new IllegalArgumentException("path [" + path + "] is not valid");

View File

@ -366,6 +366,12 @@ public class IngestDocumentTests extends ESTestCase {
assertThat(ingestDocument.getSourceAndMetadata().get("_ingest"), equalTo("value"));
}
public void testSetIngestSourceObject() {
//test that we don't strip out the _source prefix when _ingest is used
ingestDocument.setFieldValue("_ingest._source", "value");
assertThat(ingestDocument.getIngestMetadata().get("_source"), equalTo("value"));
}
public void testSetEmptyPathAfterStrippingOutPrefix() {
try {
ingestDocument.setFieldValue("_source.", "value");