Java Code Examples for org.apache.solr.client.solrj.response.schema.SchemaResponse#DynamicFieldResponse
The following examples show how to use
org.apache.solr.client.solrj.response.schema.SchemaResponse#DynamicFieldResponse .
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 |
@Test public void testDeleteDynamicFieldAccuracy() throws Exception { String dynamicFieldName = "*_del"; Map<String, Object> fieldAttributes = new LinkedHashMap<>(); fieldAttributes.put("name", dynamicFieldName); fieldAttributes.put("type", "string"); SchemaRequest.AddDynamicField addFieldUpdateSchemaRequest = new SchemaRequest.AddDynamicField(fieldAttributes); SchemaResponse.UpdateResponse addDynamicFieldResponse = addFieldUpdateSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(addDynamicFieldResponse); SchemaRequest.DynamicField dynamicFieldSchemaRequest = new SchemaRequest.DynamicField(dynamicFieldName); SchemaResponse.DynamicFieldResponse initialDFieldResponse = dynamicFieldSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(initialDFieldResponse); Map<String, Object> fieldAttributesResponse = initialDFieldResponse.getDynamicField(); assertThat(dynamicFieldName, is(equalTo(fieldAttributesResponse.get("name")))); SchemaRequest.DeleteDynamicField deleteFieldRequest = new SchemaRequest.DeleteDynamicField(dynamicFieldName); SchemaResponse.UpdateResponse deleteDynamicFieldResponse = deleteFieldRequest.process(getSolrClient()); assertValidSchemaResponse(deleteDynamicFieldResponse); expectThrows(SolrException.class, () -> dynamicFieldSchemaRequest.process(getSolrClient())); }
Example 2
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testGetDynamicFieldAccuracy() throws Exception { String dynamicFieldName = "*_i"; SchemaRequest.DynamicField dynamicFieldSchemaRequest = new SchemaRequest.DynamicField(dynamicFieldName); SchemaResponse.DynamicFieldResponse dynamicFieldResponse = dynamicFieldSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(dynamicFieldResponse); Map<String, Object> dynamicFieldAttributes = dynamicFieldResponse.getDynamicField(); assertThat(dynamicFieldName, is(equalTo(dynamicFieldAttributes.get("name")))); assertThat("int", is(equalTo(dynamicFieldAttributes.get("type")))); }
Example 3
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testAddDynamicFieldAccuracy() throws Exception { SchemaRequest.DynamicFields dynamicFieldsSchemaRequest = new SchemaRequest.DynamicFields(); SchemaResponse.DynamicFieldsResponse initialDFieldsResponse = dynamicFieldsSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(initialDFieldsResponse); List<Map<String, Object>> initialDFields = initialDFieldsResponse.getDynamicFields(); String dFieldName = "*_acc"; Map<String, Object> fieldAttributes = new LinkedHashMap<>(); fieldAttributes.put("name", dFieldName); fieldAttributes.put("type", "string"); fieldAttributes.put("stored", false); fieldAttributes.put("indexed", true); // Dynamic fields cannot be required or have a default value SchemaRequest.AddDynamicField addFieldUpdateSchemaRequest = new SchemaRequest.AddDynamicField(fieldAttributes); SchemaResponse.UpdateResponse addFieldResponse = addFieldUpdateSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldResponse); SchemaResponse.DynamicFieldsResponse currentDFieldsResponse = dynamicFieldsSchemaRequest.process(getSolrClient()); assertEquals(0, currentDFieldsResponse.getStatus()); List<Map<String, Object>> currentFields = currentDFieldsResponse.getDynamicFields(); assertEquals(initialDFields.size() + 1, currentFields.size()); SchemaRequest.DynamicField dFieldRequest = new SchemaRequest.DynamicField(dFieldName); SchemaResponse.DynamicFieldResponse newFieldResponse = dFieldRequest.process(getSolrClient()); assertValidSchemaResponse(newFieldResponse); Map<String, Object> newFieldAttributes = newFieldResponse.getDynamicField(); assertThat(dFieldName, is(equalTo(newFieldAttributes.get("name")))); assertThat("string", is(equalTo(newFieldAttributes.get("type")))); assertThat(false, is(equalTo(newFieldAttributes.get("stored")))); assertThat(true, is(equalTo(newFieldAttributes.get("indexed")))); }
Example 4
Source File: SchemaTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testReplaceDynamicFieldAccuracy() throws Exception { // Given String fieldName = "*_replace"; Map<String, Object> fieldAttributes = new LinkedHashMap<>(); fieldAttributes.put("name", fieldName); fieldAttributes.put("type", "string"); fieldAttributes.put("stored", false); fieldAttributes.put("indexed", true); SchemaRequest.AddDynamicField addDFieldUpdateSchemaRequest = new SchemaRequest.AddDynamicField(fieldAttributes); SchemaResponse.UpdateResponse addFieldResponse = addDFieldUpdateSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(addFieldResponse); // When : update the field definition Map<String, Object> replaceFieldAttributes = new LinkedHashMap<>(fieldAttributes); replaceFieldAttributes.put("stored", true); replaceFieldAttributes.put("indexed", false); SchemaRequest.ReplaceDynamicField replaceFieldRequest = new SchemaRequest.ReplaceDynamicField(replaceFieldAttributes); SchemaResponse.UpdateResponse replaceFieldResponse = replaceFieldRequest.process(getSolrClient()); assertValidSchemaResponse(replaceFieldResponse); // Then SchemaRequest.DynamicField dynamicFieldSchemaRequest = new SchemaRequest.DynamicField(fieldName); SchemaResponse.DynamicFieldResponse newFieldResponse = dynamicFieldSchemaRequest.process(getSolrClient()); assertValidSchemaResponse(newFieldResponse); Map<String, Object> newFieldAttributes = newFieldResponse.getDynamicField(); assertThat(fieldName, is(equalTo(newFieldAttributes.get("name")))); assertThat("string", is(equalTo(newFieldAttributes.get("type")))); assertThat(true, is(equalTo(newFieldAttributes.get("stored")))); assertThat(false, is(equalTo(newFieldAttributes.get("indexed")))); }
Example 5
Source File: SchemaRequest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override protected SchemaResponse.DynamicFieldResponse createResponse(SolrClient client) { return new SchemaResponse.DynamicFieldResponse(); }