use of org.apache.solr.client.solrj.request.schema.AnalyzerDefinition in project lucene-solr by apache.
the class SchemaTest method addFieldTypeWithAnalyzerClassAccuracy.
@Test
public void addFieldTypeWithAnalyzerClassAccuracy() throws Exception {
Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>();
String fieldTypeName = "nameText";
fieldTypeAttributes.put("name", fieldTypeName);
fieldTypeAttributes.put("class", "solr.TextField");
FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition();
fieldTypeDefinition.setAttributes(fieldTypeAttributes);
Map<String, Object> analyzerAttributes = new LinkedHashMap<>();
analyzerAttributes.put("class", "org.apache.lucene.analysis.core.WhitespaceAnalyzer");
analyzerAttributes.put("luceneMatchVersion", "5.0.0");
AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition();
analyzerDefinition.setAttributes(analyzerAttributes);
fieldTypeDefinition.setAnalyzer(analyzerDefinition);
SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition);
SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(getSolrClient());
assertValidSchemaResponse(addFieldTypeResponse);
SchemaRequest.FieldType fieldTypeRequest = new SchemaRequest.FieldType(fieldTypeName);
SchemaResponse.FieldTypeResponse newFieldTypeResponse = fieldTypeRequest.process(getSolrClient());
assertValidSchemaResponse(newFieldTypeResponse);
FieldTypeRepresentation newFieldTypeRepresentation = newFieldTypeResponse.getFieldType();
assertThat(fieldTypeName, is(equalTo(newFieldTypeRepresentation.getAttributes().get("name"))));
assertThat(analyzerAttributes.get("class"), is(equalTo(newFieldTypeRepresentation.getAnalyzer().getAttributes().get("class"))));
assertThat(analyzerAttributes.get("luceneMatchVersion"), is(equalTo(newFieldTypeRepresentation.getAnalyzer().getAttributes().get("luceneMatchVersion"))));
}
Aggregations