Java Code Examples for org.apache.solr.client.solrj.response.schema.SchemaResponse#FieldsResponse

The following examples show how to use org.apache.solr.client.solrj.response.schema.SchemaResponse#FieldsResponse . 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 5 votes vote down vote up
@Test
public void testGetFieldsAccuracy() throws Exception {
  SchemaRequest.Fields fieldsSchemaRequest = new SchemaRequest.Fields();
  SchemaResponse.FieldsResponse fieldsResponse = fieldsSchemaRequest.process(getSolrClient());
  assertValidSchemaResponse(fieldsResponse);
  List<Map<String, Object>> fields = fieldsResponse.getFields();
  assertThat(fields.isEmpty(), is(false));
}
 
Example 2
Source File: SchemaTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddFieldAccuracy() throws Exception {
  SchemaRequest.Fields fieldsSchemaRequest = new SchemaRequest.Fields();
  SchemaResponse.FieldsResponse initialFieldsResponse = fieldsSchemaRequest.process(getSolrClient());
  assertValidSchemaResponse(initialFieldsResponse);
  List<Map<String, Object>> initialFields = initialFieldsResponse.getFields();

  String fieldName = "accuracyField";
  Map<String, Object> fieldAttributes = new LinkedHashMap<>();
  fieldAttributes.put("name", fieldName);
  fieldAttributes.put("type", "string");
  fieldAttributes.put("stored", false);
  fieldAttributes.put("indexed", true);
  fieldAttributes.put("default", "accuracy");
  fieldAttributes.put("required", true);
  SchemaRequest.AddField addFieldUpdateSchemaRequest =
      new SchemaRequest.AddField(fieldAttributes);
  SchemaResponse.UpdateResponse addFieldResponse = addFieldUpdateSchemaRequest.process(getSolrClient());
  assertValidSchemaResponse(addFieldResponse);

  SchemaResponse.FieldsResponse currentFieldsResponse = fieldsSchemaRequest.process(getSolrClient());
  assertEquals(0, currentFieldsResponse.getStatus());
  List<Map<String, Object>> currentFields = currentFieldsResponse.getFields();
  assertEquals(initialFields.size() + 1, currentFields.size());


  SchemaRequest.Field fieldSchemaRequest = new SchemaRequest.Field(fieldName);
  SchemaResponse.FieldResponse newFieldResponse = fieldSchemaRequest.process(getSolrClient());
  assertValidSchemaResponse(newFieldResponse);
  Map<String, Object> newFieldAttributes = newFieldResponse.getField();
  assertThat(fieldName, 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"))));
  assertThat("accuracy", is(equalTo(newFieldAttributes.get("default"))));
  assertThat(true, is(equalTo(newFieldAttributes.get("required"))));
}
 
Example 3
Source File: SchemaRequest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
protected SchemaResponse.FieldsResponse createResponse(SolrClient client) {
  return new SchemaResponse.FieldsResponse();
}