Examples of CommonsHttpSolrServer


Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

    doIt(commonsHttpSolrServer);
  }

  @Test
  public void testWithBinary()throws Exception{
    CommonsHttpSolrServer commonsHttpSolrServer = (CommonsHttpSolrServer) getSolrServer();
    commonsHttpSolrServer.setRequestWriter(new BinaryRequestWriter());
    commonsHttpSolrServer.deleteByQuery( "*:*" ); // delete everything!
    doIt(commonsHttpSolrServer);
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

    doIt(commonsHttpSolrServer);
  }

  @Test
  public void testWithBinaryBean()throws Exception{
    CommonsHttpSolrServer commonsHttpSolrServer = (CommonsHttpSolrServer) getSolrServer();
    commonsHttpSolrServer.setRequestWriter(new BinaryRequestWriter());
    commonsHttpSolrServer.deleteByQuery( "*:*" ); // delete everything!
    final int[] counter = new int[1];
    counter[0] = 0;
    commonsHttpSolrServer.addBeans(new Iterator<Bean>() {

      public boolean hasNext() {
        return counter[0] < numdocs;
      }

      public Bean next() {
        Bean bean = new Bean();
        bean.id = "" + (++counter[0]);
        bean.cat = "foocat";
        return bean;
      }

      public void remove() {
        //do nothing
      }
    });
    commonsHttpSolrServer.commit();
    SolrQuery query = new SolrQuery("*:*");
    QueryResponse response = commonsHttpSolrServer.query(query);
    assertEquals(0, response.getStatus());
    assertEquals(numdocs, response.getResults().getNumFound());
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

    SolrServer server = getSolrServer();
   
    // save the old parser, so we can set it back.
    ResponseParser oldParser = null;
    if (server instanceof CommonsHttpSolrServer) {
      CommonsHttpSolrServer cserver = (CommonsHttpSolrServer) server;
      oldParser = cserver.getParser();
    }
   
    try {
      for (int iteration = 0; iteration < numIterations; iteration++) {
        // choose format
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

  private SolrServer createServer( String name )
  {
    try {
      // setup the server...
      String url = "http://localhost:"+port+context+"/"+name;
      CommonsHttpSolrServer s = new CommonsHttpSolrServer( url );
      s.setConnectionTimeout(100); // 1/10th sec
      s.setDefaultMaxConnectionsPerHost(100);
      s.setMaxTotalConnections(100);
      return s;
    }
    catch( Exception ex ) {
      throw new RuntimeException( ex );
    }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

  public SolrServer createNewSolrServer()
  {
    try {
      // setup the server...
      String url = "http://localhost:"+port+context;       // smaller queue size hits locks more often
      CommonsHttpSolrServer s = new StreamingUpdateSolrServer( url, 2, 5 ) {
        @Override
        public void handleError(Throwable ex) {
          // do something...    TODO?
        }
      };
      s.setConnectionTimeout(100); // 1/10th sec
      s.setDefaultMaxConnectionsPerHost(100);
      s.setMaxTotalConnections(100);
      return s;
    }
    catch( Exception ex ) {
      throw new RuntimeException( ex );
    }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

  protected SolrServer createNewSolrServer(int port) {
    try {
      // setup the server...
      String url = "http://localhost:" + port + context;
      CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);
      s.setConnectionTimeout(100); // 1/10th sec
      s.setDefaultMaxConnectionsPerHost(100);
      s.setMaxTotalConnections(100);
      return s;
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
    }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

  private static SolrServer createNewSolrServer(int port) {
    try {
      // setup the server...
      String url = "http://localhost:" + port + context;
      CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);
      s.setDefaultMaxConnectionsPerHost(100);
      s.setMaxTotalConnections(100);
      return s;
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
    }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

    try {
      // switched to a local address to avoid going out on the net, ns lookup issues, etc.
      // set a 1ms timeout to let the connection fail faster.
      HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
      httpClient.getParams().setParameter("http.connection.timeout", new Integer(1));
      SolrServer client = new CommonsHttpSolrServer("http://localhost:11235/solr/", httpClient);
      SolrQuery query = new SolrQuery("test123");
      client.query(query);
    } catch (SolrServerException sse) {
      gotExpectedError = true;
      /***
      assertTrue(UnknownHostException.class == sse.getRootCause().getClass()
              //If one is using OpenDNS, then you don't get UnknownHostException, instead you get back that the query couldn't execute
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("command", "full-import");
    params.set("clean", "false");
    req.setParams(params);
    String url = "http://localhost:" + jetty.getLocalPort() + "/solr";
    CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(url);
    solrServer.request(req);
    ModifiableSolrParams qparams = new ModifiableSolrParams();
    qparams.add("q", "*:*");
    QueryResponse qres = solrServer.query(qparams);
    SolrDocumentList results = qres.getResults();
    assertEquals(2, results.getNumFound());
    SolrDocument doc = results.get(0);
    assertEquals("1", doc.getFieldValue("id"));
    assertEquals("Hello C1", ((List)doc.getFieldValue("desc")).get(0));
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

  protected SolrServer createNewSolrServer() {
    try {
      // setup the server...
      String url = "http://localhost:" + port + context;
      CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);
      s.setConnectionTimeout(100); // 1/10th sec
      s.setDefaultMaxConnectionsPerHost(100);
      s.setMaxTotalConnections(100);
      return s;
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.