org.apache.solr.client.solrj.request.schema.FieldTypeDefinition Java Examples
The following examples show how to use
org.apache.solr.client.solrj.request.schema.FieldTypeDefinition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 6 votes |
private static SchemaRequest.AddFieldType createFieldTypeRequest(String fieldTypeName) { FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); fieldTypeAttributes.put("name", fieldTypeName); fieldTypeAttributes.put("class", "solr.TextField"); fieldTypeDefinition.setAttributes(fieldTypeAttributes); AnalyzerDefinition indexAnalyzerDefinition = new AnalyzerDefinition(); Map<String, Object> iTokenizerAttributes = new LinkedHashMap<>(); iTokenizerAttributes.put("class", "solr.PathHierarchyTokenizerFactory"); iTokenizerAttributes.put("delimiter", "/"); indexAnalyzerDefinition.setTokenizer(iTokenizerAttributes); fieldTypeDefinition.setIndexAnalyzer(indexAnalyzerDefinition); AnalyzerDefinition queryAnalyzerDefinition = new AnalyzerDefinition(); Map<String, Object> qTokenizerAttributes = new LinkedHashMap<>(); qTokenizerAttributes.put("class", "solr.KeywordTokenizerFactory"); queryAnalyzerDefinition.setTokenizer(qTokenizerAttributes); fieldTypeDefinition.setQueryAnalyzer(queryAnalyzerDefinition); return new SchemaRequest.AddFieldType(fieldTypeDefinition); }
Example #2
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void addFieldTypeShouldntBeCalledTwiceWithTheSameName() throws Exception { Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); String fieldName = "failureInt"; fieldTypeAttributes.put("name", fieldName); fieldTypeAttributes.put("class", RANDOMIZED_NUMERIC_FIELDTYPES.get(Integer.class)); fieldTypeAttributes.put("omitNorms", true); fieldTypeAttributes.put("positionIncrementGap", 0); FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); fieldTypeDefinition.setAttributes(fieldTypeAttributes); SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition); SchemaResponse.UpdateResponse addFieldTypeFirstResponse = addFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldTypeFirstResponse); assertFailedSchemaResponse(() -> addFieldTypeRequest.process(getSolrClient()), "Field type '" + fieldName + "' already exists."); }
Example #3
Source File: SolrSchemaChecker.java From vind with Apache License 2.0 | 5 votes |
public static void checkSchema(InputStream solrSchemaPath, SchemaResponse response) throws IOException, SchemaValidationException { // read the local schema.xml final Document local; try { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); final DocumentBuilder builder = factory.newDocumentBuilder(); local = builder.parse(solrSchemaPath); } catch (ParserConfigurationException | SAXException e) { log.error("Error checking schema.xml: {}", e.getMessage(), e); throw new IOException(e); } final SchemaRepresentation remote = response.getSchemaRepresentation(); final Element schema = local.getDocumentElement(); // check the field-types final NodeList fieldTypes = schema.getElementsByTagName("fieldType"); final Set<String> fieldTypeNames = remote.getFieldTypes().stream() .map(FieldTypeDefinition::getAttributes) .map(m -> m.get("name")) .filter(Objects::nonNull) .map(String::valueOf) .collect(Collectors.toSet()); for (int i = 0; i < fieldTypes.getLength(); i++) { final Node fieldType = fieldTypes.item(i); final String fieldTypeName = fieldType.getAttributes().getNamedItem("name").getNodeValue(); if (! fieldTypeNames.contains(fieldTypeName)) { throw new SchemaValidationException(String.format("Missing <fieldType name='%s' />", fieldTypeName)); } } // TODO: check local -> remote. }
Example #4
Source File: SchemaResponse.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static void fillFieldTypeDefinition(FieldTypeDefinition fieldTypeDefinition, NamedList<Object> fieldTypeNamedList) { Map<String, Object> fieldTypeAttributes = extractAttributeMap(fieldTypeNamedList); fieldTypeDefinition.setAttributes(fieldTypeAttributes); NamedList<Object> analyzerNamedList = (NamedList<Object>) fieldTypeNamedList.get("analyzer"); if (analyzerNamedList != null) { AnalyzerDefinition analyzerDefinition = createAnalyzerDefinition(analyzerNamedList); fieldTypeDefinition.setAnalyzer(analyzerDefinition); } NamedList<Object> indexAnalyzerNamedList = (NamedList<Object>) fieldTypeNamedList.get("indexAnalyzer"); if (indexAnalyzerNamedList != null) { AnalyzerDefinition indexAnalyzerDefinition = createAnalyzerDefinition(indexAnalyzerNamedList); fieldTypeDefinition.setIndexAnalyzer(indexAnalyzerDefinition); } NamedList<Object> queryAnalyzerNamedList = (NamedList<Object>) fieldTypeNamedList.get("queryAnalyzer"); if (queryAnalyzerNamedList != null) { AnalyzerDefinition queryAnalyzerDefinition = createAnalyzerDefinition(queryAnalyzerNamedList); fieldTypeDefinition.setQueryAnalyzer(queryAnalyzerDefinition); } NamedList<Object> multiTermAnalyzerNamedList = (NamedList<Object>) fieldTypeNamedList.get("multiTermAnalyzer"); if (multiTermAnalyzerNamedList != null) { AnalyzerDefinition multiTermAnalyzerDefinition = createAnalyzerDefinition(multiTermAnalyzerNamedList); fieldTypeDefinition.setMultiTermAnalyzer(multiTermAnalyzerDefinition); } NamedList<Object> similarityNamedList = (NamedList<Object>) fieldTypeNamedList.get("similarity"); if (similarityNamedList != null) { Map<String, Object> similarityAttributes = extractAttributeMap(similarityNamedList); fieldTypeDefinition.setSimilarity(similarityAttributes); } }
Example #5
Source File: SchemaResponse.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static List<FieldTypeDefinition> getFieldTypeDefinitions( @SuppressWarnings({"rawtypes"})Map schemaNamedList) { List<FieldTypeDefinition> fieldTypeDefinitions = new LinkedList<>(); List<NamedList<Object>> fieldsResponse = (List<NamedList<Object>>) schemaNamedList.get("fieldTypes"); for (NamedList<Object> fieldNamedList : fieldsResponse) { FieldTypeDefinition fieldTypeDefinition = createFieldTypeDefinition(fieldNamedList); fieldTypeDefinitions.add(fieldTypeDefinition); } return fieldTypeDefinitions; }
Example #6
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void addFieldTypeWithSimilarityAccuracy() throws Exception { FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); String fieldTypeName = "fullClassNames"; fieldTypeAttributes.put("name", fieldTypeName); fieldTypeAttributes.put("class", "org.apache.solr.schema.TextField"); fieldTypeDefinition.setAttributes(fieldTypeAttributes); AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition(); Map<String, Object> charFilterAttributes = new LinkedHashMap<>(); charFilterAttributes.put("class", "solr.PatternReplaceCharFilterFactory"); charFilterAttributes.put("replacement", "$1$1"); charFilterAttributes.put("pattern", "([a-zA-Z])\\\\1+"); analyzerDefinition.setCharFilters(Collections.singletonList(charFilterAttributes)); Map<String, Object> tokenizerAttributes = new LinkedHashMap<>(); tokenizerAttributes.put("class", "solr.WhitespaceTokenizerFactory"); analyzerDefinition.setTokenizer(tokenizerAttributes); fieldTypeDefinition.setAnalyzer(analyzerDefinition); Map<String, Object> similarityAttributes = new LinkedHashMap<>(); similarityAttributes.put("class", "org.apache.lucene.misc.SweetSpotSimilarity"); fieldTypeDefinition.setSimilarity(similarityAttributes); SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition); SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldTypeResponse); // similarity is not shown by default for the fieldType 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(similarityAttributes.get("class"), is(equalTo(newFieldTypeRepresentation.getSimilarity().get("class")))); }
Example #7
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@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")))); }
Example #8
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testDeleteFieldTypeAccuracy() throws Exception { Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); String fieldTypeName = "delInt"; fieldTypeAttributes.put("name", fieldTypeName); fieldTypeAttributes.put("class", RANDOMIZED_NUMERIC_FIELDTYPES.get(Integer.class)); fieldTypeAttributes.put("omitNorms", true); fieldTypeAttributes.put("positionIncrementGap", 0); FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); fieldTypeDefinition.setAttributes(fieldTypeAttributes); SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition); SolrClient c = getSolrClient(); SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(c); assertValidSchemaResponse(addFieldTypeResponse); SchemaRequest.FieldType fieldTypeRequest = new SchemaRequest.FieldType(fieldTypeName); SchemaResponse.FieldTypeResponse initialFieldTypeResponse = fieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(initialFieldTypeResponse); FieldTypeRepresentation responseFieldTypeRepresentation = initialFieldTypeResponse.getFieldType(); assertThat(fieldTypeName, is(equalTo(responseFieldTypeRepresentation.getAttributes().get("name")))); SchemaRequest.DeleteFieldType deleteFieldTypeRequest = new SchemaRequest.DeleteFieldType(fieldTypeName); SchemaResponse.UpdateResponse deleteFieldTypeResponse = deleteFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(deleteFieldTypeResponse); try { fieldTypeRequest.process(getSolrClient()); fail(String.format(Locale.ROOT, "after removal, the field type %s shouldn't be anymore available over Schema API", fieldTypeName)); } catch (SolrException e) { //success } }
Example #9
Source File: DocValuesNotIndexedTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private static AddFieldType getType(String... args) { FieldTypeDefinition ftd = new FieldTypeDefinition(); Map<String, Object> ftas = new LinkedHashMap<>(); for (int idx = 0; idx < args.length; idx += 2) { ftas.put(args[idx], args[idx + 1]); } ftd.setAttributes(ftas); return new SchemaRequest.AddFieldType(ftd); }
Example #10
Source File: SchemaValidationExceptionTest.java From vind with Apache License 2.0 | 4 votes |
@Before public void init() throws IOException, SolrServerException, URISyntaxException { solrSchemaPath = Paths.get(Resources.getResource(TEST_SOLR_SCHEMA).toURI()); MockitoAnnotations.initMocks(this); Map<String, Object> stringFieldTypeAttributes = new HashMap<>(); stringFieldTypeAttributes.put("name","string"); when(stringFieldTypeDefinition.getAttributes()).thenReturn(stringFieldTypeAttributes); Map<String, Object> booleanFieldTypeAttributes = new HashMap<>(); booleanFieldTypeAttributes.put("name","boolean"); when(booleanFieldTypeDefinition.getAttributes()).thenReturn(booleanFieldTypeAttributes); Map<String, Object> intFieldTypeAttributes = new HashMap<>(); intFieldTypeAttributes.put("name","int"); when(intFieldTypeDefinition.getAttributes()).thenReturn(intFieldTypeAttributes); Map<String, Object> floatFieldTypeAttributes = new HashMap<>(); floatFieldTypeAttributes.put("name","float"); when(floatFieldTypeDefinition.getAttributes()).thenReturn(floatFieldTypeAttributes); Map<String, Object> longFieldTypeAttributes = new HashMap<>(); longFieldTypeAttributes.put("name","long"); when(longFieldTypeDefinition.getAttributes()).thenReturn(longFieldTypeAttributes); Map<String, Object> doubleFieldTypeAttributes = new HashMap<>(); doubleFieldTypeAttributes.put("name","double"); when(doubleFieldTypeDefinition.getAttributes()).thenReturn(doubleFieldTypeAttributes); Map<String, Object> dateFieldTypeAttributes = new HashMap<>(); dateFieldTypeAttributes.put("name","date"); when(dateFieldTypeDefinition.getAttributes()).thenReturn(dateFieldTypeAttributes); Map<String, Object> textGeneralFieldTypeAttributes = new HashMap<>(); textGeneralFieldTypeAttributes.put("name","text_general"); when(textGeneralFieldTypeDefinition.getAttributes()).thenReturn(textGeneralFieldTypeAttributes); Map<String, Object> textDeFieldTypeAttributes = new HashMap<>(); textDeFieldTypeAttributes.put("name","text_de"); when(textDeFieldTypeDefinition.getAttributes()).thenReturn(textDeFieldTypeAttributes); Map<String, Object> textEnFieldTypeAttributes = new HashMap<>(); textEnFieldTypeAttributes.put("name","text_en"); when(textEnFieldTypeDefinition.getAttributes()).thenReturn(textEnFieldTypeAttributes); Map<String, Object> textEsFieldTypeAttributes = new HashMap<>(); textEsFieldTypeAttributes.put("name","text_es"); when(textEsFieldTypeDefinition.getAttributes()).thenReturn(textEsFieldTypeAttributes); Map<String, Object> pathFieldTypeAttributes = new HashMap<>(); pathFieldTypeAttributes.put("name","path"); when(pathFieldTypeDefinition.getAttributes()).thenReturn(pathFieldTypeAttributes); List<FieldTypeDefinition> fieldTypeDefinitions = new ArrayList<>(); fieldTypeDefinitions.add(stringFieldTypeDefinition); fieldTypeDefinitions.add(booleanFieldTypeDefinition); fieldTypeDefinitions.add(intFieldTypeDefinition); fieldTypeDefinitions.add(floatFieldTypeDefinition); fieldTypeDefinitions.add(longFieldTypeDefinition); fieldTypeDefinitions.add(doubleFieldTypeDefinition); fieldTypeDefinitions.add(dateFieldTypeDefinition); fieldTypeDefinitions.add(textGeneralFieldTypeDefinition); fieldTypeDefinitions.add(textDeFieldTypeDefinition); fieldTypeDefinitions.add(textEnFieldTypeDefinition); fieldTypeDefinitions.add(textEsFieldTypeDefinition); fieldTypeDefinitions.add(pathFieldTypeDefinition); when(schemaRepresentation.getFieldTypes()).thenReturn(fieldTypeDefinitions); when(schemaResponse.getSchemaRepresentation()).thenReturn(schemaRepresentation); }
Example #11
Source File: SchemaResponse.java From lucene-solr with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private static FieldTypeDefinition createFieldTypeDefinition(NamedList<Object> fieldTypeNamedList) { FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); fillFieldTypeDefinition(fieldTypeDefinition, fieldTypeNamedList); return fieldTypeDefinition; }
Example #12
Source File: SchemaRepresentation.java From lucene-solr with Apache License 2.0 | 4 votes |
public List<FieldTypeDefinition> getFieldTypes() { return fieldTypes; }
Example #13
Source File: SchemaRepresentation.java From lucene-solr with Apache License 2.0 | 4 votes |
public void setFieldTypes(List<FieldTypeDefinition> fieldTypes) { this.fieldTypes = fieldTypes; }
Example #14
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testAddFieldTypeAccuracy() throws Exception { SchemaRequest.FieldTypes fieldTypesRequest = new SchemaRequest.FieldTypes(); SchemaResponse.FieldTypesResponse initialFieldTypesResponse = fieldTypesRequest.process(getSolrClient()); assertValidSchemaResponse(initialFieldTypesResponse); List<FieldTypeRepresentation> initialFieldTypes = initialFieldTypesResponse.getFieldTypes(); FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); String fieldTypeName = "accuracyTextField"; fieldTypeAttributes.put("name", fieldTypeName); fieldTypeAttributes.put("class", "solr.TextField"); fieldTypeAttributes.put("positionIncrementGap", "100"); fieldTypeDefinition.setAttributes(fieldTypeAttributes); AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition(); Map<String, Object> charFilterAttributes = new LinkedHashMap<>(); charFilterAttributes.put("class", "solr.PatternReplaceCharFilterFactory"); charFilterAttributes.put("replacement", "$1$1"); charFilterAttributes.put("pattern", "([a-zA-Z])\\\\1+"); analyzerDefinition.setCharFilters(Collections.singletonList(charFilterAttributes)); Map<String, Object> tokenizerAttributes = new LinkedHashMap<>(); tokenizerAttributes.put("class", "solr.WhitespaceTokenizerFactory"); analyzerDefinition.setTokenizer(tokenizerAttributes); Map<String, Object> filterAttributes = new LinkedHashMap<>(); filterAttributes.put("class", "solr.WordDelimiterGraphFilterFactory"); filterAttributes.put("preserveOriginal", "0"); analyzerDefinition.setFilters(Collections.singletonList(filterAttributes)); fieldTypeDefinition.setAnalyzer(analyzerDefinition); SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition); SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldTypeResponse); SchemaResponse.FieldTypesResponse currentFieldTypesResponse = fieldTypesRequest.process(getSolrClient()); assertEquals(0, currentFieldTypesResponse.getStatus()); List<FieldTypeRepresentation> currentFieldTypes = currentFieldTypesResponse.getFieldTypes(); assertEquals(initialFieldTypes.size() + 1, currentFieldTypes.size()); Map<String, Object> fieldAttributes = new LinkedHashMap<>(); String fieldName = "accuracyField"; fieldAttributes.put("name", fieldName); fieldAttributes.put("type", fieldTypeName); SchemaRequest.AddField addFieldRequest = new SchemaRequest.AddField(fieldAttributes); SchemaResponse.UpdateResponse addFieldResponse = addFieldRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldResponse); Map<String, Object> dynamicFieldAttributes = new LinkedHashMap<>(); String dynamicFieldName = "*_accuracy"; dynamicFieldAttributes.put("name", dynamicFieldName); dynamicFieldAttributes.put("type", fieldTypeName); SchemaRequest.AddDynamicField addDynamicFieldRequest = new SchemaRequest.AddDynamicField(dynamicFieldAttributes); SchemaResponse.UpdateResponse addDynamicFieldResponse = addDynamicFieldRequest.process(getSolrClient()); assertValidSchemaResponse(addDynamicFieldResponse); 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("solr.TextField", is(equalTo(newFieldTypeRepresentation.getAttributes().get("class")))); assertThat(analyzerDefinition.getTokenizer().get("class"), is(equalTo(newFieldTypeRepresentation.getAnalyzer().getTokenizer().get("class")))); }
Example #15
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testReplaceFieldTypeAccuracy() throws Exception { // a fixed value for comparison after update, be contraian from the randomized 'default' final boolean useDv = Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP); // Given Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); String fieldTypeName = "replaceInt"; fieldTypeAttributes.put("name", fieldTypeName); fieldTypeAttributes.put("class", RANDOMIZED_NUMERIC_FIELDTYPES.get(Integer.class)); fieldTypeAttributes.put("docValues", useDv); fieldTypeAttributes.put("omitNorms", true); fieldTypeAttributes.put("positionIncrementGap", 0); FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); fieldTypeDefinition.setAttributes(fieldTypeAttributes); SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition); SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldTypeResponse); // When : update the field definition fieldTypeAttributes.put("positionIncrementGap", 42); fieldTypeAttributes.put("omitNorms", false); FieldTypeDefinition replaceFieldTypeDefinition = new FieldTypeDefinition(); replaceFieldTypeDefinition.setAttributes(fieldTypeAttributes); SchemaRequest.ReplaceFieldType replaceFieldTypeRequest = new SchemaRequest.ReplaceFieldType(replaceFieldTypeDefinition); SchemaResponse.UpdateResponse replaceFieldTypeResponse = replaceFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(replaceFieldTypeResponse); // Then SchemaRequest.FieldType fieldTypeRequest = new SchemaRequest.FieldType(fieldTypeName); SchemaResponse.FieldTypeResponse newFieldTypeResponse = fieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(newFieldTypeResponse); FieldTypeRepresentation replacedFieldTypeRepresentation = newFieldTypeResponse.getFieldType(); Map<String, Object> replacedFieldTypeAttributes = replacedFieldTypeRepresentation.getAttributes(); assertThat(fieldTypeName, is(equalTo(replacedFieldTypeAttributes.get("name")))); assertThat( RANDOMIZED_NUMERIC_FIELDTYPES.get(Integer.class), is(equalTo(replacedFieldTypeAttributes.get("class")))); assertThat(false, is(equalTo(replacedFieldTypeAttributes.get("omitNorms")))); assertThat("42", is(equalTo(replacedFieldTypeAttributes.get("positionIncrementGap")))); // should be unchanged... assertThat(useDv, is(equalTo(replacedFieldTypeAttributes.get("docValues")))); }