Search in sources :

Example 1 with DirectSolrConnection

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

the class TolerantUpdateProcessorTest method update.

public String update(String chain, String xml) {
    DirectSolrConnection connection = new DirectSolrConnection(h.getCore());
    SolrRequestHandler handler = h.getCore().getRequestHandler("/update");
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.add("update.chain", chain);
    try {
        return connection.request(handler, params, xml);
    } catch (SolrException e) {
        throw (SolrException) e;
    } catch (Exception e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
    }
}
Also used : DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrException(org.apache.solr.common.SolrException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) SolrException(org.apache.solr.common.SolrException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler)

Example 2 with DirectSolrConnection

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

the class TestSubQueryTransformerCrossCore method update.

public static String update(SolrCore core, String xml) throws Exception {
    DirectSolrConnection connection = new DirectSolrConnection(core);
    SolrRequestHandler handler = core.getRequestHandler("/update");
    return connection.request(handler, null, xml);
}
Also used : DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler)

Example 3 with DirectSolrConnection

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

the class SolrTestCaseHS method getQueryResponse.

public static String getQueryResponse(String wt, SolrParams params) throws Exception {
    ModifiableSolrParams p = new ModifiableSolrParams(params);
    p.set("wt", wt);
    String path = p.get("qt");
    p.remove("qt");
    p.set("indent", "true");
    DirectSolrConnection connection = new DirectSolrConnection(h.getCore());
    String raw = connection.request(path, p, null);
    return raw;
}
Also used : ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection)

Example 4 with DirectSolrConnection

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

the class TestCrossCoreJoin method update.

public static String update(SolrCore core, String xml) throws Exception {
    DirectSolrConnection connection = new DirectSolrConnection(core);
    SolrRequestHandler handler = core.getRequestHandler("/update");
    return connection.request(handler, null, xml);
}
Also used : DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler)

Example 5 with DirectSolrConnection

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

the class TestHarness method update.

/**
   * Processes an "update" (add, commit or optimize) and
   * returns the response as a String.
   *
   * @param xml The XML of the update
   * @return The XML response to the update
   */
public String update(String xml) {
    try (SolrCore core = getCoreInc()) {
        DirectSolrConnection connection = new DirectSolrConnection(core);
        SolrRequestHandler handler = core.getRequestHandler("/update");
        // if that lookup fails
        if (handler == null) {
            handler = updater;
        }
        return connection.request(handler, null, xml);
    } catch (SolrException e) {
        throw (SolrException) e;
    } catch (Exception e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
    }
}
Also used : SolrCore(org.apache.solr.core.SolrCore) DirectSolrConnection(org.apache.solr.servlet.DirectSolrConnection) SolrException(org.apache.solr.common.SolrException) SolrException(org.apache.solr.common.SolrException) IOException(java.io.IOException) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler)

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