use of org.apache.lucene.search.suggest.document.CompletionAnalyzer in project elasticsearch by elastic.
the class CompletionFieldMapperTests method testCompletionAnalyzerSettings.
public void testCompletionAnalyzerSettings() throws Exception {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("completion").field("type", "completion").field("analyzer", "simple").field("search_analyzer", "standard").field("preserve_separators", false).field("preserve_position_increments", true).endObject().endObject().endObject().endObject().string();
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
FieldMapper fieldMapper = defaultMapper.mappers().getMapper("completion");
assertThat(fieldMapper, instanceOf(CompletionFieldMapper.class));
MappedFieldType completionFieldType = fieldMapper.fieldType();
NamedAnalyzer indexAnalyzer = completionFieldType.indexAnalyzer();
assertThat(indexAnalyzer.name(), equalTo("simple"));
assertThat(indexAnalyzer.analyzer(), instanceOf(CompletionAnalyzer.class));
CompletionAnalyzer analyzer = (CompletionAnalyzer) indexAnalyzer.analyzer();
assertThat(analyzer.preservePositionIncrements(), equalTo(true));
assertThat(analyzer.preserveSep(), equalTo(false));
NamedAnalyzer searchAnalyzer = completionFieldType.searchAnalyzer();
assertThat(searchAnalyzer.name(), equalTo("standard"));
assertThat(searchAnalyzer.analyzer(), instanceOf(CompletionAnalyzer.class));
analyzer = (CompletionAnalyzer) searchAnalyzer.analyzer();
assertThat(analyzer.preservePositionIncrements(), equalTo(true));
assertThat(analyzer.preserveSep(), equalTo(false));
}
use of org.apache.lucene.search.suggest.document.CompletionAnalyzer in project elasticsearch by elastic.
the class CompletionFieldMapperTests method testDefaultConfiguration.
public void testDefaultConfiguration() throws IOException {
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("completion").field("type", "completion").endObject().endObject().endObject().endObject().string();
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));
FieldMapper fieldMapper = defaultMapper.mappers().getMapper("completion");
assertThat(fieldMapper, instanceOf(CompletionFieldMapper.class));
MappedFieldType completionFieldType = fieldMapper.fieldType();
NamedAnalyzer indexAnalyzer = completionFieldType.indexAnalyzer();
assertThat(indexAnalyzer.name(), equalTo("simple"));
assertThat(indexAnalyzer.analyzer(), instanceOf(CompletionAnalyzer.class));
CompletionAnalyzer analyzer = (CompletionAnalyzer) indexAnalyzer.analyzer();
assertThat(analyzer.preservePositionIncrements(), equalTo(true));
assertThat(analyzer.preserveSep(), equalTo(true));
NamedAnalyzer searchAnalyzer = completionFieldType.searchAnalyzer();
assertThat(searchAnalyzer.name(), equalTo("simple"));
assertThat(searchAnalyzer.analyzer(), instanceOf(CompletionAnalyzer.class));
analyzer = (CompletionAnalyzer) searchAnalyzer.analyzer();
assertThat(analyzer.preservePositionIncrements(), equalTo(true));
assertThat(analyzer.preserveSep(), equalTo(true));
}
Aggregations