Search in sources :

Example 16 with XMLResponseParser

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

the class NoOpResponseParserTest method assertResponse.

private void assertResponse(String responseString) throws IOException {
    ResponseParser xmlResponseParser = new XMLResponseParser();
    NamedList expectedResponse = xmlResponseParser.processResponse(IOUtils.toInputStream(responseString, "UTF-8"), "UTF-8");
    List<SolrDocument> documentList = (List<SolrDocument>) expectedResponse.getAll("response").get(0);
    assertEquals(1, documentList.size());
    SolrDocument solrDocument = documentList.get(0);
    assertEquals("1234", String.valueOf(solrDocument.getFieldValue("id")));
}
Also used : SolrDocument(org.apache.solr.common.SolrDocument) ResponseParser(org.apache.solr.client.solrj.ResponseParser) XMLResponseParser(org.apache.solr.client.solrj.impl.XMLResponseParser) NoOpResponseParser(org.apache.solr.client.solrj.impl.NoOpResponseParser) NamedList(org.apache.solr.common.util.NamedList) NamedList(org.apache.solr.common.util.NamedList) List(java.util.List) XMLResponseParser(org.apache.solr.client.solrj.impl.XMLResponseParser)

Example 17 with XMLResponseParser

use of org.apache.solr.client.solrj.impl.XMLResponseParser in project streamline by hortonworks.

the class AmbariInfraWithStormLogSearchTest method setUp.

@Before
public void setUp() throws Exception {
    logSearch = new AmbariInfraWithStormLogSearch();
    Map<String, Object> conf = new HashMap<>();
    buildTestSolrApiUrl = "http://localhost:18886" + TEST_SOLR_API_PATH;
    conf.put(AmbariInfraWithStormLogSearch.SOLR_API_URL_KEY, buildTestSolrApiUrl);
    conf.put(AmbariInfraWithStormLogSearch.COLLECTION_NAME, TEST_COLLECTION_NAME);
    logSearch.init(conf);
    // we are doing some hack to change parser, since default wt (javabin) would be faster
    // but not good to construct custom result by ourselves
    HttpSolrClient solrClient = Deencapsulation.getField(logSearch, "solr");
    solrClient.setParser(new XMLResponseParser());
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) HashMap(java.util.HashMap) XMLResponseParser(org.apache.solr.client.solrj.impl.XMLResponseParser) Before(org.junit.Before)

Example 18 with XMLResponseParser

use of org.apache.solr.client.solrj.impl.XMLResponseParser in project opencast by opencast.

the class SolrServerFactory method newRemoteInstance.

/**
 * Constructor. Prepares solr connection.
 *
 * @param url
 *          the connection url to the solr server
 */
public static SolrServer newRemoteInstance(URL url) {
    try {
        CommonsHttpSolrServer server = new CommonsHttpSolrServer(url);
        server.setSoTimeout(5000);
        server.setConnectionTimeout(5000);
        server.setDefaultMaxConnectionsPerHost(100);
        server.setMaxTotalConnections(100);
        // defaults to false
        server.setFollowRedirects(false);
        server.setAllowCompression(true);
        // defaults to 0. > 1 not recommended.
        server.setMaxRetries(1);
        // binary parser is used by default
        server.setParser(new XMLResponseParser());
        return server;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : CommonsHttpSolrServer(org.apache.solr.client.solrj.impl.CommonsHttpSolrServer) XMLResponseParser(org.apache.solr.client.solrj.impl.XMLResponseParser) SolrServerException(org.apache.solr.client.solrj.SolrServerException)

Aggregations

XMLResponseParser (org.apache.solr.client.solrj.impl.XMLResponseParser)18 Test (org.junit.Test)6 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)5 StringReader (java.io.StringReader)4 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)4 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)4 BinaryResponseParser (org.apache.solr.client.solrj.impl.BinaryResponseParser)3 SolrInputDocument (org.apache.solr.common.SolrInputDocument)3 NamedList (org.apache.solr.common.util.NamedList)3 List (java.util.List)2 ResponseParser (org.apache.solr.client.solrj.ResponseParser)2 ErrorTrackingConcurrentUpdateSolrClient (org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest.ErrorTrackingConcurrentUpdateSolrClient)2 NoOpResponseParser (org.apache.solr.client.solrj.impl.NoOpResponseParser)2 RequestWriter (org.apache.solr.client.solrj.request.RequestWriter)2 SolrDocument (org.apache.solr.common.SolrDocument)2 SolrDocumentList (org.apache.solr.common.SolrDocumentList)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1