Search in sources :

Example 96 with SolrClient

use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.

the class ShowFileRequestHandlerTest method test404ViaHttp.

public void test404ViaHttp() throws SolrServerException, IOException {
    SolrClient client = getSolrClient();
    QueryRequest request = new QueryRequest(params("file", "does-not-exist-404.txt"));
    request.setPath("/admin/file");
    try {
        QueryResponse resp = request.process(client);
        fail("didn't get 404 exception");
    } catch (SolrException e) {
        assertEquals(404, e.code());
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrClient(org.apache.solr.client.solrj.SolrClient) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) SolrException(org.apache.solr.common.SolrException)

Example 97 with SolrClient

use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.

the class SchemaTest method testDeleteFieldTypeAccuracy.

@Test
public void testDeleteFieldTypeAccuracy() throws Exception {
    Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>();
    String fieldTypeName = "delInt";
    fieldTypeAttributes.put("name", fieldTypeName);
    fieldTypeAttributes.put("class", "solr.TrieIntField");
    fieldTypeAttributes.put("precisionStep", 0);
    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
    }
}
Also used : SchemaRequest(org.apache.solr.client.solrj.request.schema.SchemaRequest) FieldTypeRepresentation(org.apache.solr.client.solrj.response.schema.FieldTypeRepresentation) LinkedHashMap(java.util.LinkedHashMap) FieldTypeDefinition(org.apache.solr.client.solrj.request.schema.FieldTypeDefinition) SolrClient(org.apache.solr.client.solrj.SolrClient) SchemaResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse) SolrException(org.apache.solr.common.SolrException) Test(org.junit.Test)

Example 98 with SolrClient

use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.

the class SchemaTest method addDynamicFieldShouldntBeCalledTwiceWithTheSameName.

@Test
public void addDynamicFieldShouldntBeCalledTwiceWithTheSameName() throws Exception {
    Map<String, Object> fieldAttributes = new LinkedHashMap<>();
    fieldAttributes.put("name", "*_failure");
    fieldAttributes.put("type", "string");
    SchemaRequest.AddDynamicField addDFieldUpdateSchemaRequest = new SchemaRequest.AddDynamicField(fieldAttributes);
    SolrClient client = getSolrClient();
    SchemaResponse.UpdateResponse addDFieldFirstResponse = addDFieldUpdateSchemaRequest.process(client);
    assertValidSchemaResponse(addDFieldFirstResponse);
    SchemaResponse.UpdateResponse addDFieldSecondResponse = addDFieldUpdateSchemaRequest.process(getSolrClient());
    assertEquals(0, addDFieldSecondResponse.getStatus());
    assertNotNull(addDFieldSecondResponse.getResponse().get("errors"));
}
Also used : SchemaRequest(org.apache.solr.client.solrj.request.schema.SchemaRequest) SolrClient(org.apache.solr.client.solrj.SolrClient) SchemaResponse(org.apache.solr.client.solrj.response.schema.SchemaResponse) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 99 with SolrClient

use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.

the class TestSolrConfigHandlerCloud method setupHarnesses.

private void setupHarnesses() {
    for (final SolrClient client : clients) {
        RestTestHarness harness = new RestTestHarness(((HttpSolrClient) client)::getBaseURL);
        restTestHarnesses.add(harness);
    }
}
Also used : RestTestHarness(org.apache.solr.util.RestTestHarness) SolrClient(org.apache.solr.client.solrj.SolrClient) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 100 with SolrClient

use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.

the class TestSolrConfigHandlerConcurrent method setupHarnesses.

private void setupHarnesses() {
    for (final SolrClient client : clients) {
        RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
        restTestHarnesses.add(harness);
    }
}
Also used : RestTestHarness(org.apache.solr.util.RestTestHarness) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) SolrClient(org.apache.solr.client.solrj.SolrClient) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient)

Aggregations

SolrClient (org.apache.solr.client.solrj.SolrClient)170 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)104 Test (org.junit.Test)67 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)37 ArrayList (java.util.ArrayList)35 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)31 SolrQuery (org.apache.solr.client.solrj.SolrQuery)28 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)28 SolrInputDocument (org.apache.solr.common.SolrInputDocument)28 IOException (java.io.IOException)24 NamedList (org.apache.solr.common.util.NamedList)22 SolrException (org.apache.solr.common.SolrException)18 SolrServerException (org.apache.solr.client.solrj.SolrServerException)17 Map (java.util.Map)16 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)16 Replica (org.apache.solr.common.cloud.Replica)16 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)15 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)14 SolrDocument (org.apache.solr.common.SolrDocument)14 ZkStateReader (org.apache.solr.common.cloud.ZkStateReader)13