Search in sources :

Example 6 with DirectSolrConnection

use of org.apache.solr.servlet.DirectSolrConnection in project lucene-solr by apache.

the class SolrTestCaseJ4 method updateJ.

/** Send JSON update commands */
public static String updateJ(String json, SolrParams args) throws Exception {
    SolrCore core = h.getCore();
    if (args == null) {
        args = params("wt", "json", "indent", "true");
    } else {
        ModifiableSolrParams newArgs = new ModifiableSolrParams(args);
        if (newArgs.get("wt") == null)
            newArgs.set("wt", "json");
        if (newArgs.get("indent") == null)
            newArgs.set("indent", "true");
        args = newArgs;
    }
    DirectSolrConnection connection = new DirectSolrConnection(core);
    SolrRequestHandler handler = core.getRequestHandler("/update/json");
    if (handler == null) {
        handler = new UpdateRequestHandler();
        handler.init(null);
    }
    return connection.request(handler, args, json);
}
Also used : SolrCore(org.apache.solr.core.SolrCore) UpdateRequestHandler(org.apache.solr.handler.UpdateRequestHandler) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler)

Example 7 with DirectSolrConnection

use of org.apache.solr.servlet.DirectSolrConnection in project lucene-solr by apache.

the class TestIndexSearcher method addDummyDoc.

private void addDummyDoc(SolrCore core) throws Exception {
    DirectSolrConnection connection = new DirectSolrConnection(core);
    SolrRequestHandler handler = core.getRequestHandler("/update");
    connection.request(handler, null, adoc("id", "1"));
}
Also used : DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler)

Example 8 with DirectSolrConnection

use of org.apache.solr.servlet.DirectSolrConnection in project lucene-solr by apache.

the class TestIndexSearcher method doQuery.

private void doQuery(SolrCore core) throws Exception {
    DirectSolrConnection connection = new DirectSolrConnection(core);
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.add("q", "*:*");
    assertTrue(connection.request("/select", params, null).contains("<int name=\"status\">0</int>"));
}
Also used : DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Aggregations

DirectSolrConnection (org.apache.solr.servlet.DirectSolrConnection)8 SolrRequestHandler (org.apache.solr.request.SolrRequestHandler)6 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)4 IOException (java.io.IOException)2 SolrException (org.apache.solr.common.SolrException)2 SolrCore (org.apache.solr.core.SolrCore)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 UpdateRequestHandler (org.apache.solr.handler.UpdateRequestHandler)1 SAXException (org.xml.sax.SAXException)1