Example usage for org.apache.solr.client.solrj.impl BinaryRequestWriter BinaryRequestWriter

List of usage examples for org.apache.solr.client.solrj.impl BinaryRequestWriter BinaryRequestWriter

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.impl BinaryRequestWriter BinaryRequestWriter.

Prototype

BinaryRequestWriter

Source Link

Usage

From source file:com.mmj.app.lucene.solr.client.SolrClient.java

License:Open Source License

private HttpSolrServer newSolrServer(String solrServerUrl) {
    HttpSolrServer solrServer = new HttpSolrServer(solrServerUrl);
    solrServer.setSoTimeout(60000);//  w w  w  .  j a va  2  s. c om
    solrServer.setConnectionTimeout(5000);
    solrServer.setDefaultMaxConnectionsPerHost(50);
    solrServer.setMaxTotalConnections(100);
    solrServer.setFollowRedirects(false);
    solrServer.setAllowCompression(false);
    solrServer.setMaxRetries(1);
    solrServer.setParser(new BinaryResponseParser());
    solrServer.setRequestWriter(new BinaryRequestWriter());
    commit();
    return solrServer;
}

From source file:com.smartitengineering.dao.solr.impl.SingletonRemoteServerFactory.java

License:Open Source License

@Override
public SolrServer getSolrServer() {
    if (solrServer == null) {
        try {/*from  w w  w . j a va 2 s.  c  o m*/
            HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
            CommonsHttpSolrServer commonsHttpClientSolrServer = new CommonsHttpSolrServer(
                    configuration.getUri(), client);
            commonsHttpClientSolrServer.setAllowCompression(configuration.isAllowCompression());
            commonsHttpClientSolrServer.setConnectionTimeout(configuration.getConnectionTimeout());
            commonsHttpClientSolrServer
                    .setDefaultMaxConnectionsPerHost(configuration.getDefaultMaxConnectionsPerHost());
            commonsHttpClientSolrServer.setFollowRedirects(configuration.isFollowRedirects());
            commonsHttpClientSolrServer.setMaxRetries(configuration.getMaxRetries());
            commonsHttpClientSolrServer.setMaxTotalConnections(configuration.getMaxTotalConnections());
            commonsHttpClientSolrServer.setParser(configuration.getResponseParser());
            commonsHttpClientSolrServer.setSoTimeout(configuration.getSocketTimeout());
            commonsHttpClientSolrServer.setRequestWriter(new BinaryRequestWriter());
            this.solrServer = commonsHttpClientSolrServer;
        } catch (Exception ex) {
            logger.error("Could not intialize solr server", ex);
        }
    }
    return solrServer;
}

From source file:de.archeoinf.indexing.mods2solr.SearchEngineSolr.java

License:Open Source License

public static void startRemoteSolr(String host, String port, String basepath, boolean cleanIndex)
        throws SolrServerException, IOException {

    StreamingUpdateSolrServer solr = new StreamingUpdateSolrServer(host + ":" + port + basepath, 20, 2);

    solr.setRequestWriter(new BinaryRequestWriter());

    if (cleanIndex == true) {
        solr.deleteByQuery("*:*");
        solr.commit();// w  ww  . j a v a  2s.c  om
    }

    solrServer = solr;
}

From source file:de.qaware.chronix.storage.solr.ChronixSolrCloudStorage.java

License:Apache License

/**
 * Fetches a stream of time series only from a single node with HttpSolrClient.
 *
 * @param shardUrl/* w w w .j  av  a 2s.  com*/
 * @param query
 * @param converter
 * @return
 */
private Stream<MetricTimeSeries> streamWithHttpSolrClient(String shardUrl, SolrQuery query,
        TimeSeriesConverter<MetricTimeSeries> converter) {
    HttpSolrClient solrClient = getSingleNodeSolrClient(shardUrl);
    solrClient.setRequestWriter(new BinaryRequestWriter());
    query.set("distrib", false);
    LoggerFactory.getLogger(ChronixSolrCloudStorage.class).debug(
            "Streaming data from solr using converter {}, Solr Client {}, and Solr Query {}", converter,
            solrClient, query);
    SolrStreamingService<MetricTimeSeries> solrStreamingService = new SolrStreamingService<>(converter, query,
            solrClient, nrOfDocumentPerBatch);
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(solrStreamingService, Spliterator.SIZED),
            false);
}

From source file:dk.statsbiblioteket.doms.licensemodule.integrationtest.DomsSolrJClientTest.java

public static ArrayList<String> filterIds(ArrayList<String> ids, String queryPartAccess) throws Exception {
    solrServer.setRequestWriter(new BinaryRequestWriter()); //To avoid http error code 413/414, due to monster URI. (and it is faster)        
    String queryPartStr = AbstractSolrJClient.makeAuthIdPart(ids);

    System.out.println(queryPartStr);
    SolrQuery query = new SolrQuery(queryPartStr);
    query.setFilterQueries(queryPartAccess);
    query.setFields("recordID");
    query.set("facet", "false");
    query.setRows(ids.size());/*w  ww  .j a v a  2 s  .c o m*/
    QueryResponse response = solrServer.query(query);
    ArrayList<String> filteredIds = AbstractSolrJClient.getIdsFromResponse(response);
    return filteredIds;
}

From source file:dk.statsbiblioteket.doms.licensemodule.solr.SolrServerClient.java

public SolrServerClient(String serverUrl) {
    try {/*from   w  w  w  . ja v a  2  s . c  o  m*/
        solrServer = new HttpSolrServer(serverUrl);
        solrServer.setRequestWriter(new BinaryRequestWriter()); //To avoid http error code 413/414, due to monster URI. (and it is faster)                
    } catch (Exception e) {
        log.error("Unable to connect to solr-server:" + serverUrl, e);
    }

}

From source file:eu.annocultor.data.destinations.SolrServer.java

License:Apache License

@Override
public void startRdf() throws Exception {
    server = new CommonsHttpSolrServer(solrUrl);
    server.setRequestWriter(new BinaryRequestWriter());
}

From source file:eu.prestoprime.search.AbstractIndexer.java

License:Open Source License

protected SolrServer getSolrServer() {
    if (solr == null) {
        String solrServerUrl = SearchConstants.getString("solrUrl");
        int solrQueueSize = SearchConstants.getInt("solrQueueSize");

        try {/*from w  ww  .  j  av a 2 s .  com*/
            LOGGER.debug("Establishing new connection to StreamingUpdateSolrServer at " + solrServerUrl);
            // TODO threadCount set to 3 for first tests. Investigate for
            // optimal value
            solr = new ConcurrentUpdateSolrServer(solrServerUrl, solrQueueSize, 3);
            ((ConcurrentUpdateSolrServer) solr).setRequestWriter(new BinaryRequestWriter());
            LOGGER.info("Connected to Solr server for indexing.");
        } catch (MalformedURLException e) {
            LOGGER.fatal("Connecting to Solr server for indexing failed.");
            LOGGER.fatal(e);
        }
    }
    return solr;
}

From source file:eu.prestoprime.search.SolrServerConnection.java

License:Open Source License

/**
 * Connects to solrServer and returns the instance.
 * // w  ww  .ja  v  a  2s . c  om
 * @return
 */
public SolrServer getSolrServer() {
    if (solr == null) {
        try {
            solr = new HttpSolrServer(solrServerUrl);
            ((HttpSolrServer) solr).setRequestWriter(new BinaryRequestWriter());
            LOGGER.info("Connected to Solr server at " + solrServerUrl);
        } catch (Exception e) {
            LOGGER.fatal("Connecting to Solr server failed. URL = " + solrServerUrl);
            LOGGER.fatal(e);
        }
    }
    return solr;
}

From source file:org.alfresco.solr.SolrDocumentLoader.java

License:Open Source License

public static SolrServer getRemoteServer() throws MalformedURLException {
    CommonsHttpSolrServer solr = new CommonsHttpSolrServer("http://localhost:8080/solr/test");
    solr.setRequestWriter(new BinaryRequestWriter());
    return solr;/* w ww.j a v  a2s .c  o m*/
}