Search in sources :

Example 1 with FieldResponse

use of org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse in project lucene-solr by apache.

the class TestInPlaceUpdatesDistrib method checkExpectedSchemaField.

/**
   * Use the schema API to verify that the specified expected Field exists with those exact attributes. 
   */
public void checkExpectedSchemaField(Map<String, Object> expected) throws Exception {
    String fieldName = (String) expected.get("name");
    assertNotNull("expected contains no name: " + expected, fieldName);
    FieldResponse rsp = new Field(fieldName).process(this.cloudClient);
    assertNotNull("Field Null Response: " + fieldName, rsp);
    assertEquals("Field Status: " + fieldName + " => " + rsp.toString(), 0, rsp.getStatus());
    assertEquals("Field: " + fieldName, expected, rsp.getField());
}
Also used : Field(org.apache.solr.client.solrj.request.schema.SchemaRequest.Field) FieldResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse)

Example 2 with FieldResponse

use of org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse in project lucene-solr by apache.

the class TestStressCloudBlindAtomicUpdates method checkExpectedSchemaField.

/**
   * Use the schema API to verify that the specified expected Field exists with those exact attributes. 
   * @see #CLOUD_CLIENT
   */
public static void checkExpectedSchemaField(Map<String, Object> expected) throws Exception {
    String fieldName = (String) expected.get("name");
    assertNotNull("expected contains no name: " + expected, fieldName);
    FieldResponse rsp = new Field(fieldName).process(CLOUD_CLIENT);
    assertNotNull("Field Null Response: " + fieldName, rsp);
    assertEquals("Field Status: " + fieldName + " => " + rsp.toString(), 0, rsp.getStatus());
    assertEquals("Field: " + fieldName, expected, rsp.getField());
}
Also used : SolrInputField(org.apache.solr.common.SolrInputField) Field(org.apache.solr.client.solrj.request.schema.SchemaRequest.Field) FieldResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse)

Example 3 with FieldResponse

use of org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse in project lucene-solr by apache.

the class PreAnalyzedFieldManagedSchemaCloudTest method addField.

private void addField(Map<String, Object> field) throws Exception {
    CloudSolrClient client = cluster.getSolrClient();
    UpdateResponse addFieldResponse = new SchemaRequest.AddField(field).process(client, COLLECTION);
    assertNotNull(addFieldResponse);
    assertEquals(0, addFieldResponse.getStatus());
    assertNull(addFieldResponse.getResponse().get("errors"));
    FieldResponse fieldResponse = new SchemaRequest.Field(field.get("name").toString()).process(client, COLLECTION);
    assertNotNull(fieldResponse);
    assertEquals(0, fieldResponse.getStatus());
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse.UpdateResponse) SchemaRequest(org.apache.solr.client.solrj.request.schema.SchemaRequest) FieldResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 4 with FieldResponse

use of org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse in project lucene-solr by apache.

the class TestCloudPseudoReturnFields method testMultiValued.

public void testMultiValued() throws Exception {
    // score as psuedo field - precondition checks
    for (String name : new String[] { "score", "val_ss" }) {
        try {
            FieldResponse frsp = new Field(name, params("includeDynamic", "true", "showDefaults", "true")).process(CLOUD_CLIENT);
            assertNotNull("Test depends on a (dynamic) field matching '" + name + "', Null response", frsp);
            assertEquals("Test depends on a (dynamic) field matching '" + name + "', bad status: " + frsp.toString(), 0, frsp.getStatus());
            assertNotNull("Test depends on a (dynamic) field matching '" + name + "', schema was changed out from under us? ... " + frsp.toString(), frsp.getField());
            assertEquals("Test depends on a multivalued dynamic field matching '" + name + "', schema was changed out from under us? ... " + frsp.toString(), Boolean.TRUE, frsp.getField().get("multiValued"));
        } catch (SolrServerException e) {
            assertEquals("Couldn't fetch field for '" + name + "' ... schema changed out from under us?", null, e);
        }
    }
    SolrDocument doc = null;
    // score as psuedo field
    doc = assertSearchOneDoc(params("q", "*:*", "fq", "id:42", "fl", "id,score,val_ss,val2_ss"));
    assertEquals("42", doc.getFieldValue("id"));
    assertEquals(1.0F, doc.getFieldValue("score"));
    // no value for val2_ss or val_ss ... yet...
    assertEquals("" + doc, 2, doc.size());
    // TODO: update this test & TestPseudoReturnFields to index docs using a (multivalued) "val_ss" instead of "ssto"
    //
    // that way we can first sanity check a single value in a multivalued field is returned correctly
    // as a "List" of one element, *AND* then we could be testing that a (single valued) psuedo-field correctly
    // overrides that actual (real) value in a multivalued field (ie: not returning a an List)
    //
    // (NOTE: not doing this yet due to how it will impact most other tests, many of which are currently
    // @AwaitsFix'ed)
    //
    //assertTrue(doc.getFieldValue("val_ss").getClass().toString(),
    //           doc.getFieldValue("val_ss") instanceof List);
    // single value int using alias that matches multivalued dynamic field
    doc = assertSearchOneDoc(params("q", "id:42", "fl", "val_ss:val_i, val2_ss:10"));
    assertEquals("" + doc, 2, doc.size());
    assertEquals("" + doc, 1, doc.getFieldValue("val_ss"));
    assertEquals("" + doc, 10L, doc.getFieldValue("val2_ss"));
}
Also used : Field(org.apache.solr.client.solrj.request.schema.SchemaRequest.Field) SolrDocument(org.apache.solr.common.SolrDocument) SolrServerException(org.apache.solr.client.solrj.SolrServerException) FieldResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse)

Example 5 with FieldResponse

use of org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse in project lucene-solr by apache.

the class TestEmbeddedSolrServerSchemaAPI method thereIsNoFieldYet.

@Before
public void thereIsNoFieldYet() throws SolrServerException, IOException {
    try {
        FieldResponse process = new SchemaRequest.Field(fieldName).process(server);
        fail("" + process);
    } catch (SolrException e) {
        assertTrue(e.getMessage().contains("No") && e.getMessage().contains("VerificationTest"));
    }
}
Also used : SchemaRequest(org.apache.solr.client.solrj.request.schema.SchemaRequest) FieldResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse) SolrException(org.apache.solr.common.SolrException) Before(org.junit.Before)

Aggregations

FieldResponse (org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse)5 Field (org.apache.solr.client.solrj.request.schema.SchemaRequest.Field)3 SchemaRequest (org.apache.solr.client.solrj.request.schema.SchemaRequest)2 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)1 UpdateResponse (org.apache.solr.client.solrj.response.schema.SchemaResponse.UpdateResponse)1 SolrDocument (org.apache.solr.common.SolrDocument)1 SolrException (org.apache.solr.common.SolrException)1 SolrInputField (org.apache.solr.common.SolrInputField)1 Before (org.junit.Before)1