• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AnalysisRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.index.analysis.AnalysisRegistry的典型用法代码示例。如果您正苦于以下问题:Java AnalysisRegistry类的具体用法?Java AnalysisRegistry怎么用?Java AnalysisRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AnalysisRegistry类属于org.elasticsearch.index.analysis包,在下文中一共展示了AnalysisRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: IngestService

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public IngestService(Settings settings, ThreadPool threadPool,
                     Environment env, ScriptService scriptService, AnalysisRegistry analysisRegistry,
                     List<IngestPlugin> ingestPlugins) {

    final TemplateService templateService = new InternalTemplateService(scriptService);
    Processor.Parameters parameters = new Processor.Parameters(env, scriptService, templateService,
        analysisRegistry, threadPool.getThreadContext());
    Map<String, Processor.Factory> processorFactories = new HashMap<>();
    for (IngestPlugin ingestPlugin : ingestPlugins) {
        Map<String, Processor.Factory> newProcessors = ingestPlugin.getProcessors(parameters);
        for (Map.Entry<String, Processor.Factory> entry : newProcessors.entrySet()) {
            if (processorFactories.put(entry.getKey(), entry.getValue()) != null) {
                throw new IllegalArgumentException("Ingest processor [" + entry.getKey() + "] is already registered");
            }
        }
    }
    this.pipelineStore = new PipelineStore(settings, Collections.unmodifiableMap(processorFactories));
    this.pipelineExecutionService = new PipelineExecutionService(pipelineStore, threadPool);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:IngestService.java


示例2: testAnalyzerAlias

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAnalyzerAlias() throws IOException {
    Settings settings = Settings.builder()
        .put("index.analysis.analyzer.foobar.alias","default")
        .put("index.analysis.analyzer.foobar.type", "keyword")
        .put("index.analysis.analyzer.foobar_search.alias","default_search")
        .put("index.analysis.analyzer.foobar_search.type","english")
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        // analyzer aliases are only allowed in 2.x indices
        .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_3_5))
        .build();
    AnalysisRegistry newRegistry = getNewRegistry(settings);
    IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings);
    assertThat(indexAnalyzers.get("default").analyzer(), is(instanceOf(KeywordAnalyzer.class)));
    assertThat(indexAnalyzers.get("default_search").analyzer(), is(instanceOf(EnglishAnalyzer.class)));
    assertWarnings("setting [index.analysis.analyzer.foobar.alias] is only allowed on index [test] because it was created before " +
                    "5.x; analyzer aliases can no longer be created on new indices.",
            "setting [index.analysis.analyzer.foobar_search.alias] is only allowed on index [test] because it was created before " +
                    "5.x; analyzer aliases can no longer be created on new indices.");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:AnalysisModuleTests.java


示例3: testAnalyzerAliasReferencesAlias

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAnalyzerAliasReferencesAlias() throws IOException {
    Settings settings = Settings.builder()
        .put("index.analysis.analyzer.foobar.alias","default")
        .put("index.analysis.analyzer.foobar.type", "german")
        .put("index.analysis.analyzer.foobar_search.alias","default_search")
        .put("index.analysis.analyzer.foobar_search.type", "default")
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        // analyzer aliases are only allowed in 2.x indices
        .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_3_5))
        .build();
    AnalysisRegistry newRegistry = getNewRegistry(settings);
    IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings);

    assertThat(indexAnalyzers.get("default").analyzer(), is(instanceOf(GermanAnalyzer.class)));
    // analyzer types are bound early before we resolve aliases
    assertThat(indexAnalyzers.get("default_search").analyzer(), is(instanceOf(StandardAnalyzer.class)));
    assertWarnings("setting [index.analysis.analyzer.foobar.alias] is only allowed on index [test] because it was created before " +
            "5.x; analyzer aliases can no longer be created on new indices.",
            "setting [index.analysis.analyzer.foobar_search.alias] is only allowed on index [test] because it was created before " +
                    "5.x; analyzer aliases can no longer be created on new indices.");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:AnalysisModuleTests.java


示例4: testAnalyzerAliasMoreThanOnce

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAnalyzerAliasMoreThanOnce() throws IOException {
    Settings settings = Settings.builder()
        .put("index.analysis.analyzer.foobar.alias","default")
        .put("index.analysis.analyzer.foobar.type", "keyword")
        .put("index.analysis.analyzer.foobar1.alias","default")
        .put("index.analysis.analyzer.foobar1.type", "english")
        // analyzer aliases are only allowed in 2.x indices
        .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_3_5))
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        .build();
    AnalysisRegistry newRegistry = getNewRegistry(settings);
    IllegalStateException ise = expectThrows(IllegalStateException.class, () -> getIndexAnalyzers(newRegistry, settings));
    assertEquals("alias [default] is already used by [foobar]", ise.getMessage());
    assertWarnings("setting [index.analysis.analyzer.foobar.alias] is only allowed on index [test] because it was created before " +
            "5.x; analyzer aliases can no longer be created on new indices.",
            "setting [index.analysis.analyzer.foobar1.alias] is only allowed on index [test] because it was created before " +
                    "5.x; analyzer aliases can no longer be created on new indices.");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:AnalysisModuleTests.java


示例5: testVersionedAnalyzers

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testVersionedAnalyzers() throws Exception {
    String yaml = "/org/elasticsearch/index/analysis/test1.yml";
    Settings settings2 = Settings.builder()
            .loadFromStream(yaml, getClass().getResourceAsStream(yaml))
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_0_0)
            .build();
    AnalysisRegistry newRegistry = getNewRegistry(settings2);
    IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings2);

    // registry always has the current version
    assertThat(newRegistry.getAnalyzer("default"), is(instanceOf(NamedAnalyzer.class)));
    NamedAnalyzer defaultNamedAnalyzer = (NamedAnalyzer) newRegistry.getAnalyzer("default");
    assertThat(defaultNamedAnalyzer.analyzer(), is(instanceOf(StandardAnalyzer.class)));
    assertEquals(Version.CURRENT.luceneVersion, defaultNamedAnalyzer.analyzer().getVersion());

    // analysis service has the expected version
    assertThat(indexAnalyzers.get("standard").analyzer(), is(instanceOf(StandardAnalyzer.class)));
    assertEquals(Version.V_2_0_0.luceneVersion, indexAnalyzers.get("standard").analyzer().getVersion());
    assertEquals(Version.V_2_0_0.luceneVersion, indexAnalyzers.get("thai").analyzer().getVersion());

    assertThat(indexAnalyzers.get("custom7").analyzer(), is(instanceOf(StandardAnalyzer.class)));
    assertEquals(org.apache.lucene.util.Version.fromBits(3,6,0), indexAnalyzers.get("custom7").analyzer().getVersion());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:AnalysisModuleTests.java


示例6: testRegisterIndexStore

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testRegisterIndexStore() throws IOException {
    final Settings settings = Settings
        .builder()
        .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        .put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), "foo_store")
        .build();
    IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings);
    IndexModule module = new IndexModule(indexSettings,
            new AnalysisRegistry(environment, emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    module.addIndexStore("foo_store", FooStore::new);
    try {
        module.addIndexStore("foo_store", FooStore::new);
        fail("already registered");
    } catch (IllegalArgumentException ex) {
        // fine
    }

    IndexService indexService = newIndexService(module);
    assertTrue(indexService.getIndexStore() instanceof FooStore);

    indexService.close("simon says", false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:IndexModuleTests.java


示例7: testListener

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testListener() throws IOException {
    Setting<Boolean> booleanSetting = Setting.boolSetting("index.foo.bar", false, Property.Dynamic, Property.IndexScope);
    IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(index, settings, booleanSetting),
            new AnalysisRegistry(environment, emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    Setting<Boolean> booleanSetting2 = Setting.boolSetting("index.foo.bar.baz", false, Property.Dynamic, Property.IndexScope);
    AtomicBoolean atomicBoolean = new AtomicBoolean(false);
    module.addSettingsUpdateConsumer(booleanSetting, atomicBoolean::set);

    try {
        module.addSettingsUpdateConsumer(booleanSetting2, atomicBoolean::set);
        fail("not registered");
    } catch (IllegalArgumentException ex) {

    }

    IndexService indexService = newIndexService(module);
    assertSame(booleanSetting, indexService.getIndexSettings().getScopedSettings().get(booleanSetting.getKey()));

    indexService.close("simon says", false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:IndexModuleTests.java


示例8: tokenFilterFactory

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public static TokenFilterFactory tokenFilterFactory(String name) throws IOException {
    Settings settings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("path.home", System.getProperty("path.home", "/tmp"))
            .build();
    Environment environment = new Environment(settings);
    AnalysisRegistry analysisRegistry = analysisService(settings);
    IndexMetaData indexMetaData = IndexMetaData.builder("test")
            .settings(settings)
            .numberOfShards(1)
            .numberOfReplicas(1)
            .build();
    IndexSettings indexSettings = new IndexSettings(indexMetaData, settings);
    Map<String, TokenFilterFactory> map = analysisRegistry.buildTokenFilterFactories(indexSettings);
    return map.containsKey(name) ? map.get(name) :
            analysisRegistry.getTokenFilterProvider(name).get(environment, name);
}
 
开发者ID:jprante,项目名称:elasticsearch-plugin-bundle,代码行数:18,代码来源:MapperTestUtils.java


示例9: charFilterFactory

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public static CharFilterFactory charFilterFactory(String name) throws IOException {
    Settings settings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("path.home", System.getProperty("path.home", "/tmp"))
            .build();
    Environment environment = new Environment(settings);
    AnalysisRegistry analysisRegistry = analysisService(settings);
    IndexMetaData indexMetaData = IndexMetaData.builder("test")
            .settings(settings)
            .numberOfShards(1)
            .numberOfReplicas(1)
            .build();
    IndexSettings indexSettings = new IndexSettings(indexMetaData, settings);
    Map<String, CharFilterFactory> map = analysisRegistry.buildCharFilterFactories(indexSettings);
    return map.containsKey(name) ? map.get(name) :
            analysisRegistry.getCharFilterProvider(name).get(environment, name);
}
 
开发者ID:jprante,项目名称:elasticsearch-plugin-bundle,代码行数:18,代码来源:MapperTestUtils.java


示例10: createTestAnalysis

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
/**
 * Creates an TestAnalysis with all the default analyzers configured.
 */
public static TestAnalysis createTestAnalysis(IndexSettings indexSettings, Settings nodeSettings,
                                              AnalysisPlugin... analysisPlugins) throws IOException {
    Environment env = new Environment(nodeSettings);
    AnalysisModule analysisModule = new AnalysisModule(env, Arrays.asList(analysisPlugins));
    AnalysisRegistry analysisRegistry = analysisModule.getAnalysisRegistry();
    return new TestAnalysis(analysisRegistry.build(indexSettings),
        analysisRegistry.buildTokenFilterFactories(indexSettings),
        analysisRegistry.buildTokenizerFactories(indexSettings),
        analysisRegistry.buildCharFilterFactories(indexSettings));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:ESTestCase.java


示例11: AnalysisModule

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public AnalysisModule(Environment environment, List<AnalysisPlugin> plugins) throws IOException {
    NamedRegistry<AnalysisProvider<CharFilterFactory>> charFilters = setupCharFilters(plugins);
    NamedRegistry<org.apache.lucene.analysis.hunspell.Dictionary> hunspellDictionaries = setupHunspellDictionaries(plugins);
    hunspellService = new HunspellService(environment.settings(), environment, hunspellDictionaries.getRegistry());
    NamedRegistry<AnalysisProvider<TokenFilterFactory>> tokenFilters = setupTokenFilters(plugins, hunspellService);
    NamedRegistry<AnalysisProvider<TokenizerFactory>> tokenizers = setupTokenizers(plugins);
    NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> analyzers = setupAnalyzers(plugins);
    NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> normalizers = setupNormalizers(plugins);
    analysisRegistry = new AnalysisRegistry(environment, charFilters.getRegistry(), tokenFilters.getRegistry(), tokenizers
        .getRegistry(), analyzers.getRegistry(), normalizers.getRegistry());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:AnalysisModule.java


示例12: IndicesService

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, NamedXContentRegistry xContentRegistry,
                      ClusterSettings clusterSettings, AnalysisRegistry analysisRegistry,
                      IndexNameExpressionResolver indexNameExpressionResolver,
                      MapperRegistry mapperRegistry, NamedWriteableRegistry namedWriteableRegistry,
                      ThreadPool threadPool, IndexScopedSettings indexScopedSettings, CircuitBreakerService circuitBreakerService,
                      BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client,
                      MetaStateService metaStateService) {
    super(settings);
    this.threadPool = threadPool;
    this.pluginsService = pluginsService;
    this.nodeEnv = nodeEnv;
    this.xContentRegistry = xContentRegistry;
    this.shardsClosedTimeout = settings.getAsTime(INDICES_SHARDS_CLOSED_TIMEOUT, new TimeValue(1, TimeUnit.DAYS));
    this.analysisRegistry = analysisRegistry;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.indicesRequestCache = new IndicesRequestCache(settings);
    this.indicesQueryCache = new IndicesQueryCache(settings);
    this.mapperRegistry = mapperRegistry;
    this.namedWriteableRegistry = namedWriteableRegistry;
    indexingMemoryController = new IndexingMemoryController(settings, threadPool,
                                                            // ensure we pull an iter with new shards - flatten makes a copy
                                                            () -> Iterables.flatten(this).iterator());
    this.indexScopeSetting = indexScopedSettings;
    this.circuitBreakerService = circuitBreakerService;
    this.bigArrays = bigArrays;
    this.scriptService = scriptService;
    this.clusterService = clusterService;
    this.client = client;
    this.indicesFieldDataCache = new IndicesFieldDataCache(settings, new IndexFieldDataCache.Listener() {
        @Override
        public void onRemoval(ShardId shardId, String fieldName, boolean wasEvicted, long sizeInBytes) {
            assert sizeInBytes >= 0 : "When reducing circuit breaker, it should be adjusted with a number higher or equal to 0 and not [" + sizeInBytes + "]";
            circuitBreakerService.getBreaker(CircuitBreaker.FIELDDATA).addWithoutBreaking(-sizeInBytes);
        }
    });
    this.cleanInterval = INDICES_CACHE_CLEAN_INTERVAL_SETTING.get(settings);
    this.cacheCleaner = new CacheCleaner(indicesFieldDataCache, indicesRequestCache,  logger, threadPool, this.cleanInterval);
    this.metaStateService = metaStateService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:IndicesService.java


示例13: Parameters

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public Parameters(Environment env, ScriptService scriptService, TemplateService templateService,
                  AnalysisRegistry analysisRegistry, ThreadContext threadContext) {
    this.env = env;
    this.scriptService = scriptService;
    this.templateService = templateService;
    this.threadContext = threadContext;
    this.analysisRegistry = analysisRegistry;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:Processor.java


示例14: getNewRegistry

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public AnalysisRegistry getNewRegistry(Settings settings) {
    try {
        return new AnalysisModule(new Environment(settings), singletonList(new AnalysisPlugin() {
            @Override
            public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
                return singletonMap("myfilter", MyFilterTokenFilterFactory::new);
            }
        })).getAnalysisRegistry();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:AnalysisModuleTests.java


示例15: testAnalyzerAliasDefault

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAnalyzerAliasDefault() throws IOException {
    Settings settings = Settings.builder()
        .put("index.analysis.analyzer.foobar.alias","default")
        .put("index.analysis.analyzer.foobar.type", "keyword")
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        // analyzer aliases are only allowed in 2.x indices
        .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_3_5))
        .build();
    AnalysisRegistry newRegistry = getNewRegistry(settings);
    IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings);
    assertThat(indexAnalyzers.get("default").analyzer(), is(instanceOf(KeywordAnalyzer.class)));
    assertThat(indexAnalyzers.get("default_search").analyzer(), is(instanceOf(KeywordAnalyzer.class)));
    assertWarnings("setting [index.analysis.analyzer.foobar.alias] is only allowed on index [test] because it was created before " +
            "5.x; analyzer aliases can no longer be created on new indices.");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:AnalysisModuleTests.java


示例16: testAnalyzerAliasNotAllowedPost5x

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAnalyzerAliasNotAllowedPost5x() throws IOException {
    Settings settings = Settings.builder()
        .put("index.analysis.analyzer.foobar.type", "standard")
        .put("index.analysis.analyzer.foobar.alias","foobaz")
        // analyzer aliases were removed in v5.0.0 alpha6
        .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_5_0_0_beta1, null))
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        .build();
    AnalysisRegistry registry = getNewRegistry(settings);
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> getIndexAnalyzers(registry, settings));
    assertEquals("setting [index.analysis.analyzer.foobar.alias] is not supported", e.getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:AnalysisModuleTests.java


示例17: testWrapperIsBound

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testWrapperIsBound() throws IOException {
    IndexModule module = new IndexModule(indexSettings,
            new AnalysisRegistry(environment, emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    module.setSearcherWrapper((s) -> new Wrapper());
    module.engineFactory.set(new MockEngineFactory(AssertingDirectoryReader.class));

    IndexService indexService = newIndexService(module);
    assertTrue(indexService.getSearcherWrapper() instanceof Wrapper);
    assertSame(indexService.getEngineFactory(), module.engineFactory.get());
    indexService.close("simon says", false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:IndexModuleTests.java


示例18: testAddSearchOperationListener

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAddSearchOperationListener() throws IOException {
    IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(index, settings),
            new AnalysisRegistry(environment, emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    AtomicBoolean executed = new AtomicBoolean(false);
    SearchOperationListener listener = new SearchOperationListener() {

        @Override
        public void onNewContext(SearchContext context) {
            executed.set(true);
        }
    };
    module.addSearchOperationListener(listener);

    expectThrows(IllegalArgumentException.class, () -> module.addSearchOperationListener(listener));
    expectThrows(IllegalArgumentException.class, () -> module.addSearchOperationListener(null));

    IndexService indexService = newIndexService(module);
    assertEquals(2, indexService.getSearchOperationListener().size());
    assertEquals(SearchSlowLog.class, indexService.getSearchOperationListener().get(0).getClass());
    assertSame(listener, indexService.getSearchOperationListener().get(1));

    for (SearchOperationListener l : indexService.getSearchOperationListener()) {
        l.onNewContext(new TestSearchContext(null));
    }
    assertTrue(executed.get());
    indexService.close("simon says", false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:IndexModuleTests.java


示例19: testAddSimilarity

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testAddSimilarity() throws IOException {
    Settings indexSettings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("index.similarity.my_similarity.type", "test_similarity")
            .put("index.similarity.my_similarity.key", "there is a key")
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
            .build();
    IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings("foo", indexSettings),
            new AnalysisRegistry(environment, emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    module.addSimilarity("test_similarity", (string, providerSettings, indexLevelSettings) -> new SimilarityProvider() {
        @Override
        public String name() {
            return string;
        }

        @Override
        public Similarity get() {
            return new TestSimilarity(providerSettings.get("key"));
        }
    });

    IndexService indexService = newIndexService(module);
    SimilarityService similarityService = indexService.similarityService();
    assertNotNull(similarityService.getSimilarity("my_similarity"));
    assertTrue(similarityService.getSimilarity("my_similarity").get() instanceof TestSimilarity);
    assertEquals("my_similarity", similarityService.getSimilarity("my_similarity").name());
    assertEquals("there is a key", ((TestSimilarity) similarityService.getSimilarity("my_similarity").get()).key);
    indexService.close("simon says", false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:IndexModuleTests.java


示例20: testFrozen

import org.elasticsearch.index.analysis.AnalysisRegistry; //导入依赖的package包/类
public void testFrozen() {
    IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(index, settings),
            new AnalysisRegistry(environment, emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap()));
    module.freeze();
    String msg = "Can't modify IndexModule once the index service has been created";
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.addSearchOperationListener(null)).getMessage());
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.addIndexEventListener(null)).getMessage());
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.addIndexOperationListener(null)).getMessage());
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.addSimilarity(null, null)).getMessage());
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.setSearcherWrapper(null)).getMessage());
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.forceQueryCacheProvider(null)).getMessage());
    assertEquals(msg, expectThrows(IllegalStateException.class, () -> module.addIndexStore("foo", null)).getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:IndexModuleTests.java



注:本文中的org.elasticsearch.index.analysis.AnalysisRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IPv6类代码示例发布时间:2022-05-23
下一篇:
Java RepositoryConfig类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap