Search in sources :

Example 86 with SolrQueryResponse

use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.

the class TestInitParams method testMultiInitParams.

@Test
public void testMultiInitParams() {
    SolrRequestHandler handler = h.getCore().getRequestHandler("/dump6");
    SolrQueryResponse rsp = new SolrQueryResponse();
    handler.handleRequest(req("initArgs", "true"), rsp);
    NamedList nl = (NamedList) rsp.getValues().get("initArgs");
    NamedList def = (NamedList) nl.get(PluginInfo.DEFAULTS);
    assertEquals("A", def.get("a"));
    assertEquals("P", def.get("p"));
    def = (NamedList) nl.get(PluginInfo.INVARIANTS);
    assertEquals("B", def.get("b"));
    def = (NamedList) nl.get(PluginInfo.APPENDS);
    assertEquals("C", def.get("c"));
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) NamedList(org.apache.solr.common.util.NamedList) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler) Test(org.junit.Test)

Example 87 with SolrQueryResponse

use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.

the class TestInitParams method testComponentWithConflictingInitParams.

@Test
public void testComponentWithConflictingInitParams() {
    SolrRequestHandler handler = h.getCore().getRequestHandler("/dump2");
    SolrQueryResponse rsp = new SolrQueryResponse();
    handler.handleRequest(req("initArgs", "true"), rsp);
    NamedList nl = (NamedList) rsp.getValues().get("initArgs");
    NamedList def = (NamedList) nl.get(PluginInfo.DEFAULTS);
    assertEquals("A1", def.get("a"));
    def = (NamedList) nl.get(PluginInfo.INVARIANTS);
    assertEquals("B1", def.get("b"));
    def = (NamedList) nl.get(PluginInfo.APPENDS);
    assertEquals(Arrays.asList("C1", "C"), def.getAll("c"));
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) NamedList(org.apache.solr.common.util.NamedList) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler) Test(org.junit.Test)

Example 88 with SolrQueryResponse

use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.

the class TestManagedSchema method assertSchemaResource.

private void assertSchemaResource(String collection, String expectedSchemaResource) throws Exception {
    final CoreContainer cores = h.getCoreContainer();
    final CoreAdminHandler admin = new CoreAdminHandler(cores);
    SolrQueryRequest request = req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
    SolrQueryResponse response = new SolrQueryResponse();
    admin.handleRequestBody(request, response);
    assertNull("Exception on create", response.getException());
    NamedList responseValues = response.getValues();
    NamedList status = (NamedList) responseValues.get("status");
    NamedList collectionStatus = (NamedList) status.get(collection);
    String collectionSchema = (String) collectionStatus.get(CoreAdminParams.SCHEMA);
    assertEquals("Schema resource name differs from expected name", expectedSchemaResource, collectionSchema);
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) CoreContainer(org.apache.solr.core.CoreContainer) NamedList(org.apache.solr.common.util.NamedList) CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler)

Example 89 with SolrQueryResponse

use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.

the class TestManagedSchema method testDefaultSchemaFactory.

public void testDefaultSchemaFactory() throws Exception {
    deleteCore();
    initCore("solrconfig-managed-schema-test.xml", "schema-minimal.xml", tmpSolrHome.getPath());
    final CoreContainer cores = h.getCoreContainer();
    final CoreAdminHandler admin = new CoreAdminHandler(cores);
    SolrQueryRequest request = req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
    SolrQueryResponse response = new SolrQueryResponse();
    admin.handleRequestBody(request, response);
    assertNull("Exception on create", response.getException());
    assertSchemaResource(collection, "managed-schema");
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) CoreContainer(org.apache.solr.core.CoreContainer) CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler)

Example 90 with SolrQueryResponse

use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.

the class TestSearchPerf method createIndex2.

// Skip encoding for updating the index
void createIndex2(int nDocs, String... fields) throws IOException {
    Set<String> fieldSet = new HashSet<>(Arrays.asList(fields));
    SolrQueryRequest req = lrf.makeRequest();
    SolrQueryResponse rsp = new SolrQueryResponse();
    UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessingChain(null);
    UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);
    boolean foomany_s = fieldSet.contains("foomany_s");
    boolean foo1_s = fieldSet.contains("foo1_s");
    boolean foo2_s = fieldSet.contains("foo2_s");
    boolean foo4_s = fieldSet.contains("foo4_s");
    boolean foo8_s = fieldSet.contains("foo8_s");
    boolean t10_100_ws = fieldSet.contains("t10_100_ws");
    for (int i = 0; i < nDocs; i++) {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", Float.toString(i));
        if (foomany_s) {
            doc.addField("foomany_s", t(r.nextInt(nDocs * 10)));
        }
        if (foo1_s) {
            doc.addField("foo1_s", t(0));
        }
        if (foo2_s) {
            doc.addField("foo2_s", r.nextInt(2));
        }
        if (foo4_s) {
            doc.addField("foo4_s", r.nextInt(4));
        }
        if (foo8_s) {
            doc.addField("foo8_s", r.nextInt(8));
        }
        if (t10_100_ws) {
            StringBuilder sb = new StringBuilder(9 * 100);
            for (int j = 0; j < 100; j++) {
                sb.append(' ');
                sb.append(t(r.nextInt(10)));
            }
            doc.addField("t10_100_ws", sb.toString());
        }
        AddUpdateCommand cmd = new AddUpdateCommand(req);
        cmd.solrDoc = doc;
        processor.processAdd(cmd);
    }
    processor.finish();
    processor.close();
    req.close();
    assertU(commit());
    req = lrf.makeRequest();
    assertEquals(nDocs, req.getSearcher().maxDoc());
    req.close();
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) SolrInputDocument(org.apache.solr.common.SolrInputDocument) UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain) UpdateRequestProcessor(org.apache.solr.update.processor.UpdateRequestProcessor) AddUpdateCommand(org.apache.solr.update.AddUpdateCommand)

Aggregations

SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)258 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)128 Test (org.junit.Test)100 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)80 NamedList (org.apache.solr.common.util.NamedList)68 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)58 SolrCore (org.apache.solr.core.SolrCore)52 AddUpdateCommand (org.apache.solr.update.AddUpdateCommand)41 SolrInputDocument (org.apache.solr.common.SolrInputDocument)40 SolrException (org.apache.solr.common.SolrException)32 ContentStreamBase (org.apache.solr.common.util.ContentStreamBase)29 ArrayList (java.util.ArrayList)26 BufferingRequestProcessor (org.apache.solr.update.processor.BufferingRequestProcessor)24 SolrRequestHandler (org.apache.solr.request.SolrRequestHandler)22 SolrRequestInfo (org.apache.solr.request.SolrRequestInfo)21 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)20 UpdateRequestProcessor (org.apache.solr.update.processor.UpdateRequestProcessor)20 JsonLoader (org.apache.solr.handler.loader.JsonLoader)17 IOException (java.io.IOException)16 HashMap (java.util.HashMap)16