use of org.opensearch.index.mapper.CompletionFieldMapper.CompletionFieldType in project OpenSearch by opensearch-project.
the class CategoryContextMappingTests method testUnknownQueryContextParsing.
public void testUnknownQueryContextParsing() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("completion").field("type", "completion").startArray("contexts").startObject().field("name", "ctx").field("type", "category").endObject().startObject().field("name", "type").field("type", "category").endObject().endArray().endObject().endObject().endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
CompletionFieldType completionFieldType = (CompletionFieldType) mapperService.fieldType("completion");
Exception e = expectThrows(IllegalArgumentException.class, () -> completionFieldType.getContextMappings().get("brand"));
assertEquals("Unknown context name [brand], must be one of [ctx, type]", e.getMessage());
}
use of org.opensearch.index.mapper.CompletionFieldMapper.CompletionFieldType in project OpenSearch by opensearch-project.
the class CompletionSuggesterBuilderTests method mockFieldType.
@Override
protected MappedFieldType mockFieldType(String fieldName, boolean analyzerSet) {
if (analyzerSet == false) {
CompletionFieldType completionFieldType = new CompletionFieldType(fieldName, null, Collections.emptyMap());
completionFieldType.setContextMappings(new ContextMappings(contextMappings));
return completionFieldType;
}
CompletionFieldType completionFieldType = new CompletionFieldType(fieldName, new NamedAnalyzer("fieldSearchAnalyzer", AnalyzerScope.INDEX, new SimpleAnalyzer()), Collections.emptyMap());
completionFieldType.setContextMappings(new ContextMappings(contextMappings));
return completionFieldType;
}
Aggregations