org.elasticsearch.indices.analysis.IndicesAnalysisService Java Examples
The following examples show how to use
org.elasticsearch.indices.analysis.IndicesAnalysisService.
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: IkESPluginTest.java From es-ik with Apache License 2.0 | 6 votes |
@Test public void testDefaultsIcuAnalysis() { Index index = new Index("test"); Settings settings = ImmutableSettings.settingsBuilder() .put("path.home", "none") .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(ImmutableSettings.EMPTY), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector(); Injector injector = new ModulesBuilder().add( new IndexSettingsModule(index, settings), new IndexNameModule(index), new AnalysisModule(ImmutableSettings.EMPTY, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new IKAnalysisBinderProcessor())) .createChildInjector(parentInjector); AnalysisService analysisService = injector.getInstance(AnalysisService.class); TokenizerFactory tokenizerFactory = analysisService.tokenizer("ik_tokenizer"); MatcherAssert.assertThat(tokenizerFactory, instanceOf(IKTokenizerFactory.class)); }
Example #2
Source File: HanLpAnalysisTests.java From elasticsearch-analysis-hanlp with Apache License 2.0 | 6 votes |
@Test public void testDefaultsIcuAnalysis() { Index index = new Index("test"); Settings settings = settingsBuilder() .put("path.home", createTempDir()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(settings))).createInjector(); Injector injector = new ModulesBuilder().add( new IndexSettingsModule(index, settings), new IndexNameModule(index), new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new HanLpAnalysisBinderProcessor())) .createChildInjector(parentInjector); AnalysisService analysisService = injector.getInstance(AnalysisService.class); TokenizerFactory tokenizerFactory = analysisService.tokenizer("smartcn_tokenizer"); MatcherAssert.assertThat(tokenizerFactory, instanceOf(HanLpTokenizerTokenizerFactory.class)); }
Example #3
Source File: AnnotationIndicesAnalysis.java From elasticsearch-analysis-annotation with Apache License 2.0 | 6 votes |
@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 #4
Source File: IndicesService.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public IndicesService(Settings settings, IndicesLifecycle indicesLifecycle, IndicesAnalysisService indicesAnalysisService, Injector injector, NodeEnvironment nodeEnv) { super(settings); this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; this.indicesAnalysisService = indicesAnalysisService; this.injector = injector; this.pluginsService = injector.getInstance(PluginsService.class); this.indicesLifecycle.addListener(oldShardsStats); this.nodeEnv = nodeEnv; this.shardsClosedTimeout = settings.getAsTime(INDICES_SHARDS_CLOSED_TIMEOUT, new TimeValue(1, TimeUnit.DAYS)); }
Example #5
Source File: AnalysisService.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public AnalysisService(Index index, IndexSettingsService indexSettingsService, @Nullable IndicesAnalysisService indicesAnalysisService, @Nullable Map<String, AnalyzerProviderFactory> analyzerFactoryFactories, @Nullable Map<String, TokenizerFactoryFactory> tokenizerFactoryFactories, @Nullable Map<String, CharFilterFactoryFactory> charFilterFactoryFactories, @Nullable Map<String, TokenFilterFactoryFactory> tokenFilterFactoryFactories) { this(index, indexSettingsService.getSettings(), indicesAnalysisService, analyzerFactoryFactories, tokenizerFactoryFactories, charFilterFactoryFactories, tokenFilterFactoryFactories); }
Example #6
Source File: AnalysisModule.java From Elasticsearch with Apache License 2.0 | 5 votes |
public AnalysisModule(Settings settings, IndicesAnalysisService indicesAnalysisService) { Objects.requireNonNull(indicesAnalysisService); this.settings = settings; this.indicesAnalysisService = indicesAnalysisService; processors.add(new DefaultProcessor()); try { processors.add(new ExtendedProcessor()); } catch (Throwable t) { // ignore. no extended ones } }
Example #7
Source File: MapperTestUtils.java From Elasticsearch with Apache License 2.0 | 5 votes |
private static AnalysisService newAnalysisService(Settings indexSettings) { Injector parentInjector = new ModulesBuilder().add(new SettingsModule(indexSettings), new EnvironmentModule(new Environment(indexSettings))).createInjector(); Index index = new Index("test"); Injector injector = new ModulesBuilder().add( new IndexSettingsModule(index, indexSettings), new IndexNameModule(index), new AnalysisModule(indexSettings, parentInjector.getInstance(IndicesAnalysisService.class))).createChildInjector(parentInjector); return injector.getInstance(AnalysisService.class); }
Example #8
Source File: TransportAnalyzeAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, AnalyzeRequest.class, ThreadPool.Names.INDEX); this.indicesService = indicesService; this.indicesAnalysisService = indicesAnalysisService; }
Example #9
Source File: MapperTestUtils.java From elasticsearch-analysis-baseform with Apache License 2.0 | 5 votes |
public static AnalysisService newAnalysisService(Settings indexSettings) { Injector parentInjector = new ModulesBuilder().add(new SettingsModule(indexSettings), new EnvironmentModule(new Environment(indexSettings))).createInjector(); Index index = new Index("test"); Injector injector = new ModulesBuilder().add( new IndexSettingsModule(index, indexSettings), new IndexNameModule(index), new AnalysisModule(indexSettings, parentInjector.getInstance(IndicesAnalysisService.class))).createChildInjector(parentInjector); return injector.getInstance(AnalysisService.class); }
Example #10
Source File: MapperTestUtils.java From elasticsearch-analysis-baseform with Apache License 2.0 | 5 votes |
public static MapperService newMapperService(Settings settings, Client client) { Settings indexSettings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put("path.home", System.getProperty("path.home")) .put("client.type", "node") .put(settings) .build(); Index index = new Index("test"); Injector parentInjector = new ModulesBuilder() .add(new SettingsModule(indexSettings), new EnvironmentModule(new Environment(indexSettings))) .createInjector(); AnalysisModule analysisModule = new AnalysisModule(indexSettings, parentInjector.getInstance(IndicesAnalysisService.class)); new AnalysisBaseformPlugin(settings).onModule(analysisModule); Injector injector = new ModulesBuilder().add(new IndexSettingsModule(index, indexSettings), new IndexNameModule(index), analysisModule) .createChildInjector(parentInjector); AnalysisService analysisService = injector.getInstance(AnalysisService.class); SimilarityLookupService similarityLookupService = new SimilarityLookupService(index, indexSettings); Map<String, Mapper.TypeParser> mappers = registerBuiltInMappers(); Map<String, MetadataFieldMapper.TypeParser> metadataMappers = registerBuiltInMetadataMappers(); MapperRegistry mapperRegistry = new MapperRegistry(mappers, metadataMappers); return new MapperService(new Index("test"), indexSettings, analysisService, similarityLookupService, null, mapperRegistry); }
Example #11
Source File: TransportExtendedAnalyzeAction.java From elasticsearch-extended-analyze with Apache License 2.0 | 5 votes |
@Inject public TransportExtendedAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(settings, ExtendedAnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, ExtendedAnalyzeRequest.class, ThreadPool.Names.INDEX); this.indicesService = indicesService; this.indicesAnalysisService = indicesAnalysisService; }
Example #12
Source File: FulltextAnalyzerResolver.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Inject public FulltextAnalyzerResolver(ClusterService clusterService, IndicesAnalysisService indicesAnalysisService) { this.clusterService = clusterService; this.indicesAnalysisService = indicesAnalysisService; }
Example #13
Source File: IndicesModule.java From Elasticsearch with Apache License 2.0 | 4 votes |
protected void bindHunspellExtension() { hunspellDictionaries.bind(binder()); bind(HunspellService.class).asEagerSingleton(); bind(IndicesAnalysisService.class).asEagerSingleton(); }
Example #14
Source File: HanLpIndicesAnalysis.java From elasticsearch-analysis-hanlp with Apache License 2.0 | 4 votes |
@Inject public HanLpIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { super(settings); initSettings(settings); // Register hanlp analyzer indicesAnalysisService.analyzerProviderFactories().put("hanlp", new PreBuiltAnalyzerProviderFactory("hanlp", AnalyzerScope.INDICES, new HanLPAnalyzer(analyzerIndexMode, analyzerNameRecognize, analyzerTranslatedNameRecognize, analyzerJapaneseNameRecognize, analyzerPlaceRecognize, analyzerOrganizationRecognize, analyzerUseCustomDictionary, analyzerSpeechTagging, analyzerOffset, analyzerNumberQuantifierRecognize, analyzerThreads, null))); // Register hanlp_tokenizer tokenizer indicesAnalysisService.tokenizerFactories().put("hanlp_tokenizer", new PreBuiltTokenizerFactoryFactory(new TokenizerFactory() { @Override public String name() { return "hanlp_tokenizer"; } @Override public Tokenizer create() { return new HanLPTokenizer(HanLP.newSegment() .enableIndexMode(tokenizerIndexMode) .enableNameRecognize(tokenizerNameRecognize) .enableTranslatedNameRecognize(tokenizerTranslatedNameRecognize) .enableJapaneseNameRecognize(tokenizerJapaneseNameRecognize) .enablePlaceRecognize(tokenizerPlaceRecognize) .enableOrganizationRecognize(tokenizerOrganizationRecognize) .enableCustomDictionary(tokenizerUseCustomDictionary) .enablePartOfSpeechTagging(tokenizerSpeechTagging) .enableOffset(tokenizerOffset) .enableNumberQuantifierRecognize(tokenizerNumberQuantifierRecognize) .enableMultithreading(tokenizerThreads), null, tokenizerSpeechTagging); } })); // Register hanlp_word token filter -- noop indicesAnalysisService.tokenFilterFactories().put("hanlp_word", new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { @Override public String name() { return "hanlp_word"; } @Override public TokenStream create(TokenStream tokenStream) { return tokenStream; } })); }