本文整理匯總了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()));
}
}
示例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()));
}
示例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;
}
示例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));
}
示例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));
}
示例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;
}
示例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;
}
示例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)));
}