package org.elasticsearch.index.analysis;

import org.apache.lucene.analysis.TokenStream;
import org.apache.uima.lucas.indexer.analysis.HypernymFilterFactory;
import org.apache.uima.lucas.indexer.util.MultimapFileReaderFactory;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.settings.IndexSettings;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by yar on 5/6/15.
 */
public class HypernymTokenFilterFactory extends org.elasticsearch.index.analysis.AbstractTokenFilterFactory {
    private final HypernymFilterFactory filterFactoryDelegate;
    private Properties properties;

    @Inject
    public HypernymTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, String name, Settings settings) {
        super(index, indexSettings, name, settings);
        filterFactoryDelegate = new HypernymFilterFactory(new MultimapFileReaderFactory());
        if (settings.get("hypernyms_path") != null) {
            properties.put(HypernymFilterFactory.FILE_PATH_PARAMETER, indexSettings.get("hypernyms_path"));
        } else {
            throw new IllegalArgumentException("hypernym requires `hypernyms_path` to be configured");
        }

    }

    @Override
    public TokenStream create(TokenStream tokenStream) {
        try {
            return filterFactoryDelegate.createTokenFilter(tokenStream, properties);
        } catch (IOException e) {
            return tokenStream;
        }
    }
}

@@ -250,28 +250,156 @@
 rch.
-common.inject.Inject
+ElasticsearchIllegalArgumentException;%0Aimport org.elasticsearch.common.inject.Inject;%0Aimport org.elasticsearch.common.inject.assistedinject.Assisted
 ;%0Aim
@@ -946,16 +946,26 @@
 ettings,
+ @Assisted
  String 
@@ -969,16 +969,26 @@
 ng name,
+ @Assisted
  Setting
@@ -1325,16 +1325,16 @@
  else %7B%0A
-
         
@@ -1347,16 +1347,29 @@
 row new 
+Elasticsearch
 IllegalA

Fix the type of error thrown by token filter factory.