Write a Custom Meta Processor
Using the Exalead CloudView Eclipse plugin you can develop custom components such as Meta Processors.
-
Make sure that your custom processor inherits from the
Custom{Double,Long,String,Text}MetaProcessor
class. The sample below demonstrates theCustomStringMetaProcessor
class. -
Even if your component does not have any config, you must still write the annotation
with
configClass=CVComponentConfigNone.class
.
import java.util.ArrayList; import java.util.List; import com.exalead.mercury.component.CVComponentDescription; import com.exalead.mercury.component.config.CVComponentConfig; import com.exalead.mercury.component.config.CVComponentConfigClass; import com.exalead.mercury.component.config.CVComponentConfigNone; import com.exalead.search.pipeline.full.CustomStringMetaProcessor @CVComponentDescription("Prefix metavalue with test_") @CVComponentConfigClass (configClass = CVComponentConfigNone.class) public class PrefixTextMetaProcessor extends CustomStringMetaProcessor { public PrefixTextMetaProcessor(CVComponentConfig config, String metaName) { super(config, metaName); item.config = config; } /** * Entry point of the meta processor, called with the list of values, and * which must return the new list of values */ @Override public Iterable<String> onMeta(String... value) { List<String> list = new ArrayList<String>(); for (String v : value) { list.add("test_" + v); } return list; } }