org.elasticsearch.index.analysis.AnalyzerScope Java Examples

The following examples show how to use org.elasticsearch.index.analysis.AnalyzerScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationIndicesAnalysis.java    From elasticsearch-analysis-annotation with Apache License 2.0 6 votes vote down vote up
@Inject
public AnnotationIndicesAnalysis(Settings settings,
		IndicesAnalysisService indicesAnalysisService) {
	super(settings);
	indicesAnalysisService.analyzerProviderFactories().put(
			"default",
			new PreBuiltAnalyzerProviderFactory("default",
					AnalyzerScope.INDICES, new AnnotationAnalyzer(
							Lucene.ANALYZER_VERSION)));

	indicesAnalysisService.tokenFilterFactories().put("annotation_filter",
			new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
				@Override
				public String name() {
					return "annotation_filter";
				}

				@Override
				public TokenStream create(TokenStream tokenStream) {
					return new InlineAnnotationFilter(tokenStream);
				}
			}));
}
 
Example #2
Source File: KeywordFieldMapper.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public KeywordFieldMapper build(BuilderContext context) {
    setupFieldType(context);
    if (normalizerName != null) {
        NamedAnalyzer normalizer = indexAnalyzers.getNormalizer(normalizerName);
        if (normalizer == null) {
            throw new MapperParsingException("normalizer [" + normalizerName + "] not found for field [" + name + "]");
        }
        fieldType().setNormalizer(normalizer);
        final NamedAnalyzer searchAnalyzer;
        if (fieldType().splitQueriesOnWhitespace) {
            searchAnalyzer = indexAnalyzers.getWhitespaceNormalizer(normalizerName);
        } else {
            searchAnalyzer = normalizer;
        }
        fieldType().setSearchAnalyzer(searchAnalyzer);
    } else if (fieldType().splitQueriesOnWhitespace) {
        fieldType().setSearchAnalyzer(new NamedAnalyzer("whitespace", AnalyzerScope.INDEX, new WhitespaceAnalyzer()));
    }
    return new KeywordFieldMapper(
        name,
        position,
        defaultExpression,
        fieldType,
        defaultFieldType,
        ignoreAbove,
        lengthLimit,
        context.indexSettings(),
        multiFieldsBuilder.build(this, context),
        copyTo
    );
}
 
Example #3
Source File: BosonNLPIndicesAnalysis.java    From elasticsearch-analysis-bosonnlp with Apache License 2.0 5 votes vote down vote up
@Inject    
public BosonNLPIndicesAnalysis(final Settings settings, IndicesAnalysisService indicesAnalysisService) {
    super(settings);
    // Get all the arguments from settings
    this.TAG_URL = settings.get("API_URL", "").toString();
    this.BOSONNLP_API_TOKEN = settings.get("API_TOKEN", "").toString();
    this.spaceMode = Integer.parseInt(settings.get("space_mode", "0"));
    this.oovLevel = Integer.parseInt(settings.get("oov_level", "3"));
    this.t2s = Integer.parseInt(settings.get("t2s", "0"));
    this.specialCharConv = Integer.parseInt(settings.get("spechial_char_conv", "0"));
    
    // Register the bosonnlp type analyzer
    indicesAnalysisService.analyzerProviderFactories().put("bosonnlp", 
            new PreBuiltAnalyzerProviderFactory("bosonnlp", AnalyzerScope.GLOBAL, 
                    new BosonNLPAnalyzer(TAG_URL, BOSONNLP_API_TOKEN, spaceMode, oovLevel, t2s, specialCharConv)));
    
    // Register the bosonnlp type tokenizer
    indicesAnalysisService.tokenizerFactories().put("bosonnlp", 
            new PreBuiltTokenizerFactoryFactory(new TokenizerFactory(){

                @Override
                public String name() {
                    return "bosonnlp";
                }

                @Override
                public Tokenizer create() {
                    BosonNLPTokenizer BToken = null;
                    try {
                        BToken = new BosonNLPTokenizer(TAG_URL, BOSONNLP_API_TOKEN, spaceMode, oovLevel, t2s, specialCharConv);
                    } catch (JSONException | IOException | UnirestException e) {

                        e.printStackTrace();
                    }
                    return BToken;
                }
    			
            }));
		
}
 
Example #4
Source File: TranslogHandler.java    From crate with Apache License 2.0 5 votes vote down vote up
public TranslogHandler(NamedXContentRegistry xContentRegistry, IndexSettings indexSettings) {
    NamedAnalyzer defaultAnalyzer = new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer());
    IndexAnalyzers indexAnalyzers =
            new IndexAnalyzers(indexSettings, defaultAnalyzer, defaultAnalyzer, defaultAnalyzer, emptyMap(), emptyMap(), emptyMap());
    MapperRegistry mapperRegistry = new IndicesModule(emptyList()).getMapperRegistry();
    mapperService = new MapperService(indexSettings, indexAnalyzers, xContentRegistry, mapperRegistry,
            () -> null);
}
 
Example #5
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void normalizeOther(MappedFieldType other) {
    other.setSearchQuoteAnalyzer(new NamedAnalyzer("foo", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #6
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setSearchQuoteAnalyzer(new NamedAnalyzer("bar", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #7
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setSearchQuoteAnalyzer(new NamedAnalyzer("bar", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #8
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void normalizeOther(MappedFieldType other) {
    other.setSearchAnalyzer(new NamedAnalyzer("foo", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #9
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setSearchAnalyzer(new NamedAnalyzer("bar", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #10
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setSearchAnalyzer(new NamedAnalyzer("bar", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #11
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void normalizeOther(MappedFieldType other) {
    other.setIndexAnalyzer(new NamedAnalyzer("foo", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #12
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setIndexAnalyzer(new NamedAnalyzer("foo", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #13
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void normalizeOther(MappedFieldType other) {
    other.setIndexAnalyzer(new NamedAnalyzer("foo", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #14
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setIndexAnalyzer(new NamedAnalyzer("bar", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #15
Source File: FieldTypeTestCase.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void modify(MappedFieldType ft) {
    ft.setIndexAnalyzer(new NamedAnalyzer("bar", AnalyzerScope.INDEX, new StandardAnalyzer()));
}
 
Example #16
Source File: TextFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
PrefixFieldType setAnalyzer(NamedAnalyzer delegate) {
    setIndexAnalyzer(new NamedAnalyzer(delegate.name(), AnalyzerScope.INDEX,
        new PrefixWrappedAnalyzer(delegate.analyzer(), minChars, maxChars)));
    return this;
}
 
Example #17
Source File: TextFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
void setAnalyzer(String name, Analyzer delegate) {
    setIndexAnalyzer(new NamedAnalyzer(name, AnalyzerScope.INDEX, new PhraseWrappedAnalyzer(delegate)));
}