当前位置: 首页>>代码示例>>Java>>正文


Java PreBuiltAnalyzers类代码示例

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


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

示例1: testBuiltInAnalyzersAreCached

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public void testBuiltInAnalyzersAreCached() throws IOException {
    Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
    Settings indexSettings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);
    IndexAnalyzers indexAnalyzers = new AnalysisRegistry(new Environment(settings),
            emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap())
            .build(idxSettings);
    IndexAnalyzers otherIndexAnalyzers = new AnalysisRegistry(new Environment(settings), emptyMap(), emptyMap(), emptyMap(),
            emptyMap(), emptyMap()).build(idxSettings);
    final int numIters = randomIntBetween(5, 20);
    for (int i = 0; i < numIters; i++) {
        PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(random(), PreBuiltAnalyzers.values());
        assertSame(indexAnalyzers.get(preBuiltAnalyzers.name()), otherIndexAnalyzers.get(preBuiltAnalyzers.name()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AnalysisRegistryTests.java

示例2: testThatAnalyzersAreUsedInMapping

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public void testThatAnalyzersAreUsedInMapping() throws IOException {
    int randomInt = randomInt(PreBuiltAnalyzers.values().length-1);
    PreBuiltAnalyzers randomPreBuiltAnalyzer = PreBuiltAnalyzers.values()[randomInt];
    String analyzerName = randomPreBuiltAnalyzer.name().toLowerCase(Locale.ROOT);

    Version randomVersion = randomVersion(random());
    Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, randomVersion).build();

    NamedAnalyzer namedAnalyzer = new PreBuiltAnalyzerProvider(analyzerName, AnalyzerScope.INDEX, randomPreBuiltAnalyzer.getAnalyzer(randomVersion)).get();

    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "text").field("analyzer", analyzerName).endObject().endObject()
            .endObject().endObject().string();
    DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));

    FieldMapper fieldMapper = docMapper.mappers().getMapper("field");
    assertThat(fieldMapper.fieldType().searchAnalyzer(), instanceOf(NamedAnalyzer.class));
    NamedAnalyzer fieldMapperNamedAnalyzer = fieldMapper.fieldType().searchAnalyzer();

    assertThat(fieldMapperNamedAnalyzer.analyzer(), is(namedAnalyzer.analyzer()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:PreBuiltAnalyzerTests.java

示例3: create

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public AnalyzerProvider<?> create(String name, Settings settings) {
    Version indexVersion = Version.indexCreated(settings);
    if (!Version.CURRENT.equals(indexVersion)) {
        PreBuiltAnalyzers preBuiltAnalyzers = PreBuiltAnalyzers.getOrDefault(name, null);
        if (preBuiltAnalyzers != null) {
            Analyzer analyzer = preBuiltAnalyzers.getAnalyzer(indexVersion);
            return new PreBuiltAnalyzerProvider(name, AnalyzerScope.INDICES, analyzer);
        }
    }

    return analyzerProvider;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:PreBuiltAnalyzerProviderFactory.java

示例4: testThatDefaultAndStandardAnalyzerAreTheSameInstance

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public void testThatDefaultAndStandardAnalyzerAreTheSameInstance() {
    Analyzer currentStandardAnalyzer = PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT);
    Analyzer currentDefaultAnalyzer = PreBuiltAnalyzers.DEFAULT.getAnalyzer(Version.CURRENT);

    // special case, these two are the same instance
    assertThat(currentDefaultAnalyzer, is(currentStandardAnalyzer));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:PreBuiltAnalyzerTests.java

示例5: testThatInstancesAreCachedAndReused

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public void testThatInstancesAreCachedAndReused() {
    assertSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.CURRENT),
            PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.CURRENT));
    // same lucene version should be cached
    assertSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_2_0_0),
            PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_2_0_1));

    assertNotSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_2_0_0),
        PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_2_2_0));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:PreBuiltAnalyzerTests.java

示例6: create

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
@Override
public AnalyzerProvider create(String name, Settings settings) {
    Version indexVersion = Version.indexCreated(settings);
    if (!Version.CURRENT.equals(indexVersion)) {
        PreBuiltAnalyzers preBuiltAnalyzers = PreBuiltAnalyzers.getOrDefault(name, null);
        if (preBuiltAnalyzers != null) {
            Analyzer analyzer = preBuiltAnalyzers.getAnalyzer(indexVersion);
            return new PreBuiltAnalyzerProvider(name, AnalyzerScope.INDICES, analyzer);
        }
    }

    return analyzerProvider;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:PreBuiltAnalyzerProviderFactory.java

示例7: create

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public AnalyzerProvider<?> create(String name, Settings settings) {
  Version indexVersion = Version.indexCreated(settings);
  if (!Version.CURRENT.equals(indexVersion)) {
    PreBuiltAnalyzers preBuiltAnalyzers = PreBuiltAnalyzers.getOrDefault(name, null);
    if (preBuiltAnalyzers != null) {
      Analyzer analyzer = preBuiltAnalyzers.getAnalyzer(indexVersion);
      return new MyAnalyzerProvider(AnalyzerScope.INDICES);
    }
  }

  return analyzerProvider;
}
 
开发者ID:MysterionRise,项目名称:information-retrieval-adventure,代码行数:13,代码来源:MyAnalyzerPlugin.java

示例8: testThatInstancesAreTheSameAlwaysForKeywordAnalyzer

import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; //导入依赖的package包/类
public void testThatInstancesAreTheSameAlwaysForKeywordAnalyzer() {
    assertThat(PreBuiltAnalyzers.KEYWORD.getAnalyzer(Version.CURRENT),
            is(PreBuiltAnalyzers.KEYWORD.getAnalyzer(Version.V_2_0_0)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:PreBuiltAnalyzerTests.java


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