use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class FulltextAnalyzerResolverTest method resolveAnalyzerExtendingCustom.
@Test
public void resolveAnalyzerExtendingCustom() throws Exception {
execute("CREATE ANALYZER a5 (" + " tokenizer whitespace," + " token_filters (" + " lowercase," + " germanstemmer WITH (" + " type='stemmer'," + " language='german'" + " )" + " )" + ")");
Settings fullAnalyzerSettings = fulltextAnalyzerResolver.resolveFullCustomAnalyzerSettings("a5");
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a5.type", "custom"));
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a5.tokenizer", "whitespace"));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.analyzer.a5.filter"), arrayContainingInAnyOrder("lowercase", "a5_germanstemmer"));
assertThat(fullAnalyzerSettings.getAsMap(), allOf(hasEntry("index.analysis.filter.a5_germanstemmer.type", "stemmer"), hasEntry("index.analysis.filter.a5_germanstemmer.language", "german")));
execute("CREATE ANALYZER a5e EXTENDS a5 (" + " tokenizer letter," + " char_filters (" + " \"html_strip\"," + " mymapping WITH (" + " type='mapping'," + " mappings=['ph=>f', 'ß=>ss', 'ö=>oe']" + " )" + " )" + ")");
fullAnalyzerSettings = fulltextAnalyzerResolver.resolveFullCustomAnalyzerSettings("a5e");
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a5e.type", "custom"));
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a5e.tokenizer", "letter"));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.analyzer.a5e.filter"), arrayContainingInAnyOrder("lowercase", "a5_germanstemmer"));
assertThat(fullAnalyzerSettings.getAsMap(), allOf(hasEntry("index.analysis.filter.a5_germanstemmer.type", "stemmer"), hasEntry("index.analysis.filter.a5_germanstemmer.language", "german")));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.analyzer.a5e.char_filter"), arrayContainingInAnyOrder("html_strip", "a5e_mymapping"));
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class FulltextAnalyzerResolverTest method resolveAnalyzerExtendingBuiltin.
@Test
public void resolveAnalyzerExtendingBuiltin() throws Exception {
execute("CREATE ANALYZER a4 EXTENDS " + "german WITH (" + " \"stop_words\"=['der', 'die', 'das']" + ")");
Settings fullAnalyzerSettings = fulltextAnalyzerResolver.resolveFullCustomAnalyzerSettings("a4");
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a4.type", "german"));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.analyzer.a4.stop_words"), arrayContainingInAnyOrder("der", "die", "das"));
// extend analyzer who extends builtin analyzer (chain can be longer than 1)
execute("CREATE ANALYZER a4e EXTENDS " + "a4 WITH (" + " \"stop_words\"=['der', 'die', 'das', 'wer', 'wie', 'was']" + ")");
fullAnalyzerSettings = fulltextAnalyzerResolver.resolveFullCustomAnalyzerSettings("a4e");
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a4e.type", "german"));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.analyzer.a4e.stop_words"), arrayContainingInAnyOrder("der", "die", "das", "wer", "wie", "was"));
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class FulltextAnalyzerResolverTest method resolveAnalyzerBuiltinTokenFilter.
@Test
public void resolveAnalyzerBuiltinTokenFilter() throws Exception {
execute("CREATE ANALYZER builtin_filter (" + " tokenizer whitespace," + " token_filters (" + " ngram WITH (" + " min_gram=1" + " )" + " )" + ")");
Settings fullAnalyzerSettings = fulltextAnalyzerResolver.resolveFullCustomAnalyzerSettings("builtin_filter");
assertThat(fullAnalyzerSettings.getAsMap(), allOf(hasEntry("index.analysis.filter.builtin_filter_ngram.type", "ngram"), hasEntry("index.analysis.filter.builtin_filter_ngram.min_gram", "1")));
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class FulltextAnalyzerResolverTest method resolveAnalyzerWithCharFilters.
@Test
public void resolveAnalyzerWithCharFilters() throws Exception {
execute("CREATE ANALYZER a3" + "(" + " tokenizer lowercase," + " char_filters (" + " \"html_strip\"," + " my_mapping WITH (" + " type='mapping'," + " mappings=['ph=>f', 'ß=>ss', 'ö=>oe']" + " )" + " )" + ")");
Settings fullAnalyzerSettings = fulltextAnalyzerResolver.resolveFullCustomAnalyzerSettings("a3");
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a3.type", "custom"));
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.analyzer.a3.tokenizer", "lowercase"));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.analyzer.a3.char_filter"), arrayContainingInAnyOrder("html_strip", "a3_my_mapping"));
assertThat(fullAnalyzerSettings.getAsMap(), hasEntry("index.analysis.char_filter.a3_my_mapping.type", "mapping"));
assertThat(fullAnalyzerSettings.getAsArray("index.analysis.char_filter.a3_my_mapping" + ".mappings"), arrayContainingInAnyOrder("ph=>f", "ß=>ss", "ö=>oe"));
execute("CREATE TABLE t1(content " + "string index using fulltext with (analyzer='a3'))");
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class FulltextAnalyzerResolverTest method useAnalyzerForIndexSettings.
@Test
public void useAnalyzerForIndexSettings() throws Exception {
execute("CREATE ANALYZER a11 (" + " TOKENIZER standard," + " TOKEN_FILTERS (" + " lowercase," + " mystop WITH (" + " type='stop'," + " stopword=['the', 'over']" + " )" + " )" + ")");
Settings settings = getPersistentClusterSettings();
assertThat(settings.getAsMap(), allOf(hasKey("crate.analysis.custom.analyzer.a11"), hasKey("crate.analysis.custom.filter.a11_mystop")));
Settings analyzerSettings = FulltextAnalyzerResolver.decodeSettings(settings.get("crate.analysis.custom.analyzer.a11"));
Settings tokenFilterSettings = FulltextAnalyzerResolver.decodeSettings(settings.get("crate" + ".analysis.custom.filter.a11_mystop"));
Settings.Builder builder = Settings.builder();
builder.put(analyzerSettings);
builder.put(tokenFilterSettings);
execute("create table test (" + " id integer primary key," + " name string," + " content string index using fulltext with (analyzer='a11')" + ")");
ensureYellow();
execute("insert into test (id, name, content) values (?, ?, ?)", new Object[] { 1, "phrase", "The quick brown fox jumps over the lazy dog." });
execute("insert into test (id, name, content) values (?, ?, ?)", new Object[] { 2, "another phrase", "Don't panic!" });
refresh();
SQLResponse response = execute("select id from test where match(content, 'brown jump')");
assertEquals(1L, response.rowCount());
assertEquals(1, response.rows()[0][0]);
}
Aggregations