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


Java AnalysisService.analyzer方法代码示例

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


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

示例1: testISBN1

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testISBN1() throws IOException {
     String source = "Die ISBN von Elasticsearch in Action lautet 9781617291623";

    String[] expected = new String[] {
            "Die",
            "ISBN",
            "von",
            "Elasticsearch",
            "in",
            "Action",
            "lautet",
            "9781617291623",
            "EAN 9781617291623",
            "GTIN 9781617291623",
            "978-1-61729-162-3"
    };
    AnalysisService analysisService = createAnalysisService();
    NamedAnalyzer analyzer = analysisService.analyzer("standardnumber");
    assertSimpleTSOutput(analyzer.tokenStream("content", source), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-standardnumber,代码行数:22,代码来源:StandardNumberTokenFilterTests.java

示例2: testISBN2

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testISBN2() throws IOException {
    String source = "Die ISBN von Lucene in Action lautet 1-9339-8817-7.";

    String[] expected = new String[] {
            "Die",
            "ISBN",
            "von",
            "Lucene",
            "in",
            "Action",
            "lautet",
            "1-9339-8817-7.",
            "1-933988-17-7",
            "1933988177",
            "978-1-933988-17-7",
            "9781933988177"
    };
    AnalysisService analysisService = createAnalysisService();
    NamedAnalyzer analyzer = analysisService.analyzer("standardnumber");
    assertSimpleTSOutput(analyzer.tokenStream("content", source), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-standardnumber,代码行数:23,代码来源:StandardNumberTokenFilterTests.java

示例3: testMetaphonePhrases

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testMetaphonePhrases() throws Exception {
    Index index = new Index("test", "_na_");
    Settings settings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("index.analysis.analyzer.myAnalyzer.type", "custom")
            .put("index.analysis.analyzer.myAnalyzer.tokenizer", "standard")
            .put("index.analysis.analyzer.myAnalyzer.filter", "br_metaphone")
            .build();

    AnalysisService analysisService = createAnalysisService(index, settings, new AnalysisMetaphonePlugin());

    Analyzer analyzer = analysisService.analyzer("myAnalyzer");
    
    Map<String,List<String>> phrases = buildPhraseList();
    
    for(String phrase : phrases.keySet()) {
     List<String> outputWords = phrases.get(phrase);
     
     TokenStream ts = analyzer.tokenStream("test", phrase);
	
     CharTermAttribute term1 = ts.addAttribute(CharTermAttribute.class);
     ts.reset();
	
     for (String expected : outputWords) {
         assertThat(ts.incrementToken(), equalTo(true));
         assertThat(term1.toString(), equalTo(expected));
     }
     ts.close();
    
    }
}
 
开发者ID:anaelcarvalho,项目名称:elasticsearch-analysis-metaphone_ptBR,代码行数:33,代码来源:MetaphoneTokenFilterTests.java

示例4: testAnalyzer

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testAnalyzer() throws IOException {

    String source = "eins zwei drei";

    String[] expected = {
            "d81214940018a100"
    };
    AnalysisService analysisService = MapperTestUtils.analysisService("eudex_analysis.json");
    Analyzer analyzer = analysisService.analyzer("my_phonetic");
    assertSimpleTSOutput(analyzer.tokenStream(null, new StringReader(source)), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-phonetic-eudex,代码行数:13,代码来源:EudexAnalyzerTests.java

示例5: testDefaultsIcuAnalysis

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testDefaultsIcuAnalysis() {
    Settings settings = Settings.settingsBuilder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("path.home", System.getProperty("path.home"))
            .build();

    Index index = new Index("test");

    Injector parentInjector = new ModulesBuilder()
            .add(new SettingsModule(settings),
                    new EnvironmentModule(new Environment(settings)))
            .createInjector();
    Injector injector = new ModulesBuilder().add(
            new IndexSettingsModule(index, settings),
            new IndexNameModule(index),
            new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))
                    .addProcessor(new IcuAnalysisBinderProcessor()))
            .createChildInjector(parentInjector);

    AnalysisService analysisService = injector.getInstance(AnalysisService.class);

    TokenizerFactory tokenizerFactory = analysisService.tokenizer("icu_tokenizer");
    assertThat(tokenizerFactory, instanceOf(IcuTokenizerFactory.class));

    TokenFilterFactory filterFactory = analysisService.tokenFilter("icu_normalizer");
    assertThat(filterFactory, instanceOf(IcuNormalizerTokenFilterFactory.class));

    filterFactory = analysisService.tokenFilter("icu_folding");
    assertThat(filterFactory, instanceOf(IcuFoldingTokenFilterFactory.class));

    filterFactory = analysisService.tokenFilter("icu_transform");
    assertThat(filterFactory, instanceOf(IcuTransformTokenFilterFactory.class));

    Analyzer analyzer = analysisService.analyzer("icu_collation");
    assertThat(analyzer, instanceOf(NamedAnalyzer.class));

}
 
开发者ID:jprante,项目名称:elasticsearch-icu,代码行数:39,代码来源:IcuAnalysisTests.java

示例6: testRLPAnalysis

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testRLPAnalysis() throws Exception {
    String testString = "My hovercraft is full of eels.";
    //out.printf("Input String: %s%n", testString);
    AnalysisService analysisService = getAnalysisService();
    NamedAnalyzer englishAnalyzer = analysisService.analyzer("rosette");
    MatcherAssert.assertThat(englishAnalyzer.analyzer(), instanceOf(RLPAnalyzer.class));
    assertSimpleTSOutput(englishAnalyzer.tokenStream("test", new StringReader(testString)), new String[]{"hovercraft", "full", "eel"});
}
 
开发者ID:basis-technology-corp,项目名称:elasticsearch-analysis-rosette,代码行数:10,代码来源:SimpleRosetteAnalysisTests.java

示例7: create

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@BeforeClass
public static void create() throws IOException {
    Settings settings = Settings.settingsBuilder()
            .loadFromSource(copyToStringFromClasspath(("/org/xbib/elasticsearch/index/analysis/baseform_de.json")))
            .build();
    AnalysisService analysisService = MapperTestUtils.analysisService(settings);
    analyzer = analysisService.analyzer("baseform");
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-baseform,代码行数:9,代码来源:GermanBaseformTokenFilterTests.java

示例8: testDefaultsIcuAnalysis

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testDefaultsIcuAnalysis() {
    Settings settings = ImmutableSettings.settingsBuilder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .build();

    Index index = new Index("test");

    Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(EMPTY_SETTINGS)), new IndicesAnalysisModule()).createInjector();
    Injector injector = new ModulesBuilder().add(
            new IndexSettingsModule(index, settings),
            new IndexNameModule(index),
            new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))
                    .addProcessor(new IcuAnalysisBinderProcessor()))
            .createChildInjector(parentInjector);

    AnalysisService analysisService = injector.getInstance(AnalysisService.class);

    TokenizerFactory tokenizerFactory = analysisService.tokenizer("icu_tokenizer");
    assertThat(tokenizerFactory, instanceOf(IcuTokenizerFactory.class));

    TokenFilterFactory filterFactory = analysisService.tokenFilter("icu_normalizer");
    assertThat(filterFactory, instanceOf(IcuNormalizerTokenFilterFactory.class));

    filterFactory = analysisService.tokenFilter("icu_folding");
    assertThat(filterFactory, instanceOf(IcuFoldingTokenFilterFactory.class));

    filterFactory = analysisService.tokenFilter("icu_transform");
    assertThat(filterFactory, instanceOf(IcuTransformTokenFilterFactory.class));

    Analyzer analyzer = analysisService.analyzer("icu_collation");
    assertThat(analyzer, instanceOf(NamedAnalyzer.class));

}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-german,代码行数:35,代码来源:IcuAnalysisTests.java

示例9: testBasicUsage

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testBasicUsage() throws Exception {
    Settings settings = ImmutableSettings.settingsBuilder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT)
            .put("index.analysis.analyzer.myanalyzer.type", "sortform")
            .put("index.analysis.analyzer.myanalyzer.filter", "sortform")
            .build();
    AnalysisService analysisService = createAnalysisService(settings);
    NamedAnalyzer myanalyzer = analysisService.analyzer("myanalyzer");
    assertAnalyzesTo(myanalyzer, "<<Der>> Titel des Buches", new String[]{"Titel des Buches"});
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-german,代码行数:12,代码来源:SortFormTests.java

示例10: testUnicodeUsage

import org.elasticsearch.index.analysis.AnalysisService; //导入方法依赖的package包/类
@Test
public void testUnicodeUsage() throws Exception {
    Settings settings = ImmutableSettings.settingsBuilder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT)
            .put("index.analysis.analyzer.myanalyzer.type", "sortform")
            .put("index.analysis.analyzer.myanalyzer.filter", "sortform")
            .build();
    AnalysisService analysisService = createAnalysisService(settings);
    Analyzer myanalyzer = analysisService.analyzer("myanalyzer");
    // Unicode 0098: START OF STRING
    // Unicode 009C: STRING TERMINATOR
    assertAnalyzesTo(myanalyzer, "\u0098Der\u009c Titel des Buches", new String[]{"Titel des Buches"});
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-german,代码行数:14,代码来源:SortFormTests.java


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