當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。