package xyz.dowenwork.elasticsearch.indices.analysis;

import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.analysis.CharFilterFactory;
import org.elasticsearch.index.analysis.PreBuiltCharFilterFactoryFactory;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import xyz.dowenwork.lucene.analyzer.ChineseSimplifyingCharFilter;

import java.io.Reader;

/**
 * <p>create at 16-6-2</p>
 *
 * @author liufl
 * @since 2.3.3.0
 */
public class ChineseSimplifyingAnalysis extends AbstractComponent {
    @Inject
    public ChineseSimplifyingAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) {
        super(settings);
        indicesAnalysisService.charFilterFactories().put("sbc2dbc", new PreBuiltCharFilterFactoryFactory(
                new CharFilterFactory() {
                    @Override
                    public String name() {
                        return "sbc2dbc";
                    }

                    @Override
                    public Reader create(Reader tokenStream) {
                        return new ChineseSimplifyingCharFilter(tokenStream);
                    }
                }));
    }
}

@@ -840,23 +840,35 @@
 ().put(%22
-sbc2dbc
+chinese-simplifying
 %22, new P
@@ -1051,15 +1051,27 @@
 rn %22
-sbc2dbc
+chinese-simplifying
 %22;%0A 

fix name