Package org.apache.solr.client.solrj.impl

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


      SolrInputDocument doc = new SolrInputDocument();
      doc.addField("id", i);
      doc.addField("name", solrInstance.name);
      docs.add(doc);
    }
    CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(solrInstance.getUrl(), httpClient);
    UpdateResponse resp = solrServer.add(docs);
    assertEquals(0, resp.getStatus());
    resp = solrServer.commit();
    assertEquals(0, resp.getStatus());
  }
View Full Code Here


  int port = 0;
  static final String context = "/example";

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

    // this is a very simple test and most of the test should be considered verified
    // if the compiler won't let you by without the try/catch
    boolean gotExpectedError = false;
    try {
      // switched to a local address to avoid going out on the net, ns lookup issues, etc.
      SolrServer client = new CommonsHttpSolrServer("http://localhost:11235/solr/");
      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

    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", doc.getFieldValue("desc"));
View Full Code Here

  protected 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

    commonsHttpSolrServer.deleteByQuery( "*:*" ); // delete everything!   
    doIt(commonsHttpSolrServer);
  }

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

    commonsHttpSolrServer.deleteByQuery( "*:*" ); // delete everything!
    doIt(commonsHttpSolrServer);
  }

  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

  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

  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

    solrJetty = new JettySolrRunner("/solr", 0);

    solrJetty.start();
    String url = "http://localhost:" + solrJetty.getLocalPort() + "/solr";
    client = new CommonsHttpSolrServer(url);

  }
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

Copyright © 2018 www.massapicom. 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.