Examples of CommonsHttpSolrServer


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

    @Test
    public void setAddOtherSchema() throws Exception
    {

        otherClient = new CommonsHttpSolrServer("http://localhost:" + port + "/solandra/" + otherIndexName );

        String otherSchema = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
                + "<schema name=\"config\" version=\"1.2\">\n"
                + "<types>\n"
                + "<fieldType name=\"string\" class=\"solr.StrField\" sortMissingLast=\"true\" omitNorms=\"true\"/>\n"
View Full Code Here

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

    }

    public static CommonsHttpSolrServer getSolrClient(String indexName) throws MalformedURLException
    {
        CommonsHttpSolrServer client = solrClients.get(indexName);

        if (client == null)
        {
            client = new CommonsHttpSolrServer("http://localhost:" + port + "/solandra/" + indexName);
            solrClients.put(indexName, client);
        }

        return client;
    }
View Full Code Here

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

                    return doc;
                }
               
                private CommonsHttpSolrServer getStreamingServer(String url) throws MalformedURLException
                {
                    CommonsHttpSolrServer server = streamingClients.get(url);
                   
                    if(server == null)
                    {
                        synchronized (url.intern())
                        {
                            if((server = streamingClients.get(url)) == null)
                            {
                                server =  new StreamingUpdateSolrServer(url, 512, 1+(numClients/urls.length));
                                streamingClients.put(url, server);
                            }
                        }
                    }                
                   
                    return server;
                }
               
                public void run() {
                   
                    try{
                       
                        String fullUrl;
                       
                        if(indexName.equals(""))
                            fullUrl = urls[myThreadId % urls.length] + ":" + port +  "/solr";
                        else
                            fullUrl = urls[myThreadId % urls.length] + ":" + port +  "/solandra/" + (type == Type.write ? "~" : "") + indexName;
                       
                        if(type == Type.write)
                            solrClient = getStreamingServer(fullUrl);
                        else
                            solrClient = new CommonsHttpSolrServer(fullUrl);
                       
                    }catch(MalformedURLException e){
                       
                    }
                   
View Full Code Here

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

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

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

  }
View Full Code Here

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

          String url = "http://" + shard;

          params.remove(CommonParams.WT); // use default (currently javabin)
          params.remove(CommonParams.VERSION);

          SolrServer server = new CommonsHttpSolrServer(url, client);
          // SolrRequest req = new QueryRequest(SolrRequest.METHOD.POST, "/select");
          // use generic request to avoid extra processing of queries
          QueryRequest req = new QueryRequest(params);
          req.setMethod(SolrRequest.METHOD.POST);

          // no need to set the response parser as binary is the default
          // req.setResponseParser(new BinaryResponseParser());
          // srsp.rsp = server.request(req);
          // srsp.rsp = server.query(sreq.params);

          ssr.nl = server.request(req);
        } catch (Throwable th) {
          srsp.setException(th);
          if (th instanceof SolrException) {
            srsp.setResponseCode(((SolrException)th).code());
          } else {
View Full Code Here

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

  public SolrServer createNewSolrServer() {
    if (jetty != null) {
      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

  public 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);

      // where the magic happens
      s.setParser(new BinaryResponseParser());
      s.setRequestWriter(new BinaryRequestWriter());

      return s;
    }
    catch( Exception ex ) {
      throw new RuntimeException( ex );
View Full Code Here

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

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

  public void testBadSetup()
  {
    try {
      // setup the server...
      String url = "http://localhost/?core=xxx";
      CommonsHttpSolrServer s = new CommonsHttpSolrServer( url );
      Assert.fail( "CommonsHttpSolrServer should not allow a path with a parameter: "+s.getBaseURL() );
    }
    catch( Exception ex ) {
      // expected
    }
  }
View Full Code Here

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

  static final int numdocs = 1000


  @Test
  public void testWithXml() throws Exception {
    CommonsHttpSolrServer commonsHttpSolrServer = (CommonsHttpSolrServer) getSolrServer();
    commonsHttpSolrServer.setRequestWriter(new RequestWriter());
    commonsHttpSolrServer.deleteByQuery( "*:*" ); // delete everything!   
    doIt(commonsHttpSolrServer);
  }
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.