Skip to content

Commit

Permalink
Remove an existing field to get a non-existing field name
Browse files Browse the repository at this point in the history
Signed-off-by: Gao Binlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Mar 25, 2024
1 parent 8e87efb commit 955a84a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public class CopyProcessorTests extends OpenSearchTestCase {

public void testCopyExistingField() throws Exception {
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
String targetFieldName = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument);
// remove the target field to ensure that we get a non-existing field name
ingestDocument.removeField(targetFieldName);
String sourceFieldName = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument);
String targetFieldName = sourceFieldName + "_" + randomAlphaOfLength(10);
Processor processor = createCopyProcessor(sourceFieldName, targetFieldName, false, false, false);
processor.execute(ingestDocument);
assertThat(ingestDocument.hasField(targetFieldName), equalTo(true));
Expand Down Expand Up @@ -70,8 +72,11 @@ public void testCopyWithIgnoreMissing() throws Exception {

public void testCopyWithRemoveSource() throws Exception {
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
String targetFieldName = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument);
// remove the target field to ensure that we get a non-existing field name
ingestDocument.removeField(targetFieldName);
String sourceFieldName = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument);
String targetFieldName = sourceFieldName + "_" + randomAlphaOfLength(10);

Object sourceValue = ingestDocument.getFieldValue(sourceFieldName, Object.class);

Processor processor = createCopyProcessor(sourceFieldName, targetFieldName, false, true, false);
Expand Down

0 comments on commit 955a84a

Please sign in to comment.