This repository has been archived on 2023-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
va02-part3/src/main/java/usi/vaa/elasticsearch/plugin/ingest/lookup/LookupProcessor.java

77 lines
2.4 KiB
Java

/*
* Copyright [2020] [your_name]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package usi.vaa.elasticsearch.plugin.ingest.lookup;
import org.elasticsearch.common.Strings;
import org.elasticsearch.ingest.AbstractProcessor;
import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.ingest.Processor;
import java.io.IOException;
import java.util.Map;
import static org.elasticsearch.ingest.ConfigurationUtils.readMap;
import static org.elasticsearch.ingest.ConfigurationUtils.readStringProperty;
public class LookupProcessor extends AbstractProcessor {
public static final String TYPE = "lookup";
private final String field = "";
// TODO this signature and method might be incomplete - change as needed
public LookupProcessor(String tag, String description, String field,
Map<String,String> lookupMap) throws IOException {
super(tag, description);
}
@Override
public IngestDocument execute(IngestDocument ingestDocument) throws Exception{
String originalContent = ingestDocument.getFieldValue(field, String.class);
ingestDocument.setFieldValue(field, "Hello world");
return null;
}
@Override
public String getType() {
// TODO your job!
return null;
}
String getField() {
// TODO your job!
return null;
}
public static final class Factory implements Processor.Factory {
@Override
public LookupProcessor create(Map<String, Processor.Factory> factories, String tag,
String description, Map<String, Object> config)
throws Exception {
String field = readStringProperty(TYPE, tag, config, "field");
// TODO your job! Also initialize the lookup processor properly if needed, after you changed the constructor
return null;
}
}
}