当前位置: 首页>>代码示例>>Java>>正文


Java Processor.execute方法代码示例

本文整理汇总了Java中org.elasticsearch.ingest.Processor.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Processor.execute方法的具体用法?Java Processor.execute怎么用?Java Processor.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.ingest.Processor的用法示例。


在下文中一共展示了Processor.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRenameAtomicOperationRemoveFails

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testRenameAtomicOperationRemoveFails() throws Exception {
    Map<String, Object> source = new HashMap<String, Object>() {
        @Override
        public Object remove(Object key) {
            if (key.equals("list")) {
                throw new UnsupportedOperationException();
            }
            return super.remove(key);
        }
    };
    source.put("list", Collections.singletonList("item"));

    IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap());
    Processor processor = new RenameProcessor(randomAsciiOfLength(10), "list", "new_field", false);
    try {
        processor.execute(ingestDocument);
        fail("processor execute should have failed");
    } catch (UnsupportedOperationException e) {
        //the set failed, the old field has not been removed
        assertThat(ingestDocument.getSourceAndMetadata().containsKey("list"), equalTo(true));
        assertThat(ingestDocument.getSourceAndMetadata().containsKey("new_field"), equalTo(false));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RenameProcessorTests.java

示例2: testSortDoubles

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testSortDoubles() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    int numItems = randomIntBetween(1, 10);
    List<Double> fieldValue = new ArrayList<>(numItems);
    List<Double> expectedResult = new ArrayList<>(numItems);
    for (int j = 0; j < numItems; j++) {
        Double value = randomDoubleBetween(0.0, 100.0, true);
        fieldValue.add(value);
        expectedResult.add(value);
    }
    Collections.sort(expectedResult);

    SortOrder order = randomBoolean() ? SortOrder.ASCENDING : SortOrder.DESCENDING;
    if (order.equals(SortOrder.DESCENDING)) {
        Collections.reverse(expectedResult);
    }

    String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue);
    Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order);
    processor.execute(ingestDocument);
    assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:SortProcessorTests.java

示例3: testConvertBooleanError

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testConvertBooleanError() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    String fieldName = RandomDocumentPicks.randomFieldName(random());
    String fieldValue;
    if (randomBoolean()) {
        fieldValue = "string-" + randomAsciiOfLengthBetween(1, 10);
    } else {
        //verify that only proper boolean values are supported and we are strict about it
        fieldValue = randomFrom("on", "off", "yes", "no", "0", "1");
    }
    ingestDocument.setFieldValue(fieldName, fieldValue);

    Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.BOOLEAN, false);
    try {
        processor.execute(ingestDocument);
        fail("processor execute should have failed");
    } catch(Exception e) {
        assertThat(e.getMessage(), equalTo("[" + fieldValue + "] is not a boolean value, cannot convert to boolean"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ConvertProcessorTests.java

示例4: testSortBytes

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testSortBytes() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    int numItems = randomIntBetween(1, 10);
    List<Byte> fieldValue = new ArrayList<>(numItems);
    List<Byte> expectedResult = new ArrayList<>(numItems);
    for (int j = 0; j < numItems; j++) {
        Byte value = randomByte();
        fieldValue.add(value);
        expectedResult.add(value);
    }
    Collections.sort(expectedResult);

    SortOrder order = randomBoolean() ? SortOrder.ASCENDING : SortOrder.DESCENDING;
    if (order.equals(SortOrder.DESCENDING)) {
        Collections.reverse(expectedResult);
    }

    String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue);
    Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order);
    processor.execute(ingestDocument);
    assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:SortProcessorTests.java

示例5: testGsub

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testGsub() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "127.0.0.1");
    Processor processor = new GsubProcessor(randomAsciiOfLength(10), fieldName, Pattern.compile("\\."), "-");
    processor.execute(ingestDocument);
    assertThat(ingestDocument.getFieldValue(fieldName, String.class), equalTo("127-0-0-1"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:GsubProcessorTests.java

示例6: test

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void test() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    String message = randomAsciiOfLength(10);
    Processor processor = new FailProcessor(randomAsciiOfLength(10), new TestTemplateService.MockTemplate(message));
    try {
        processor.execute(ingestDocument);
        fail("fail processor should throw an exception");
    } catch (FailProcessorException e) {
        assertThat(e.getMessage(), equalTo(message));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:FailProcessorTests.java

示例7: testConvertNonExistingField

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testConvertNonExistingField() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    String fieldName = RandomDocumentPicks.randomFieldName(random());
    Type type = randomFrom(Type.values());
    Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, type, false);
    try {
        processor.execute(ingestDocument);
        fail("processor execute should have failed");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("not present as part of path [" + fieldName + "]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:ConvertProcessorTests.java

示例8: testGsubNullValue

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testGsubNullValue() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null));
    Processor processor = new GsubProcessor(randomAsciiOfLength(10), "field", Pattern.compile("\\."), "-");
    try {
        processor.execute(ingestDocument);
        fail("processor execution should have failed");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), equalTo("field [field] is null, cannot match pattern."));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:GsubProcessorTests.java

示例9: testSetExistingFields

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testSetExistingFields() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    String fieldName = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument);
    Object fieldValue = RandomDocumentPicks.randomFieldValue(random());
    Processor processor = createSetProcessor(fieldName, fieldValue, true);
    processor.execute(ingestDocument);
    assertThat(ingestDocument.hasField(fieldName), equalTo(true));
    assertThat(ingestDocument.getFieldValue(fieldName, Object.class), equalTo(fieldValue));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:SetProcessorTests.java

示例10: testSetNewFields

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testSetNewFields() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    //used to verify that there are no conflicts between subsequent fields going to be added
    IngestDocument testIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    Object fieldValue = RandomDocumentPicks.randomFieldValue(random());
    String fieldName = RandomDocumentPicks.addRandomField(random(), testIngestDocument, fieldValue);
    Processor processor = createSetProcessor(fieldName, fieldValue, true);
    processor.execute(ingestDocument);
    assertThat(ingestDocument.hasField(fieldName), equalTo(true));
    assertThat(ingestDocument.getFieldValue(fieldName, Object.class), equalTo(fieldValue));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:SetProcessorTests.java

示例11: testSetFieldsTypeMismatch

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testSetFieldsTypeMismatch() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    ingestDocument.setFieldValue("field", "value");
    Processor processor = createSetProcessor("field.inner", "value", true);
    try {
        processor.execute(ingestDocument);
        fail("processor execute should have failed");
    } catch(IllegalArgumentException e) {
        assertThat(e.getMessage(), equalTo("cannot set [inner] with parent object of type [java.lang.String] as " +
                "part of path [field.inner]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:SetProcessorTests.java

示例12: testConvertNonExistingFieldWithIgnoreMissing

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testConvertNonExistingFieldWithIgnoreMissing() throws Exception {
    IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
    String fieldName = RandomDocumentPicks.randomFieldName(random());
    Type type = randomFrom(Type.values());
    Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, type, true);
    processor.execute(ingestDocument);
    assertIngestDocument(originalIngestDocument, ingestDocument);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ConvertProcessorTests.java

示例13: testRemoveNonExistingField

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testRemoveNonExistingField() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    String fieldName = RandomDocumentPicks.randomFieldName(random());
    Processor processor = new RemoveProcessor(randomAsciiOfLength(10), new TestTemplateService.MockTemplate(fieldName));
    try {
        processor.execute(ingestDocument);
        fail("remove field should have failed");
    } catch(IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("not present as part of path [" + fieldName + "]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:RemoveProcessorTests.java

示例14: testNullValueWithIgnoreMissing

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testNullValueWithIgnoreMissing() throws Exception {
    Processor processor = newProcessor("field", true);
    IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null));
    IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
    processor.execute(ingestDocument);
    assertIngestDocument(originalIngestDocument, ingestDocument);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:AbstractStringProcessorTestCase.java

示例15: testConvertBoolean

import org.elasticsearch.ingest.Processor; //导入方法依赖的package包/类
public void testConvertBoolean() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    boolean randomBoolean = randomBoolean();
    String booleanString = Boolean.toString(randomBoolean);
    if (randomBoolean) {
        booleanString = booleanString.toUpperCase(Locale.ROOT);
    }
    String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, booleanString);

    Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.BOOLEAN, false);
    processor.execute(ingestDocument);
    assertThat(ingestDocument.getFieldValue(fieldName, Boolean.class), equalTo(randomBoolean));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:ConvertProcessorTests.java


注:本文中的org.elasticsearch.ingest.Processor.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。