lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "Solrj" by davidschorr
Date Thu, 15 Nov 2012 21:10:11 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "Solrj" page has been changed by davidschorr:
http://wiki.apache.org/solr/Solrj?action=diff&rev1=66&rev2=67

Comment:
CommonsHttpSolrServer renamed to HttpSolrServer in solr 4

  If you use solr-solrj version 1.4.1 and slf4j-simple 1.5.6 you may get IllegalAccessError
because of slf4j-api change.
  Solrj uses slf4j-api 1.5.5 so you have to use slf4j-simple 1.5.5 or other binding with appropriate
version. See [[http://www.slf4j.org/faq.html#IllegalAccessError|slf4j FAQ]].
  
- = CommonsHttpSolrServer =
+ = HttpSolrServer =
- The [[http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.html|CommonsHttpSolrServer]]
uses the [[http://jakarta.apache.org/httpcomponents/httpclient-3.x/|Apache Commons HTTP Client]]
to connect to solr.
+ The [[http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/HttpSolrServer.html|HttpSolrServer]]
uses the [[http://jakarta.apache.org/httpcomponents/httpclient-3.x/|Apache Commons HTTP Client]]
to connect to solr.  Note: CommonsHttpSolrServer was changed to HttpSolrServer and  StreamingUpdateSolrServer
is now ConcurrentUpdateSolrServer as of solr 4.0.
  
  {{{
    String url = "http://localhost:8983/solr";
    /*
-     CommonsHttpSolrServer is thread-safe and if you are using the following constructor,
+     HttpSolrServer is thread-safe and if you are using the following constructor,
      you *MUST* re-use the same instance for all requests.  If instances are created on
      the fly, it can cause a connection leak. The recommended practice is to keep a
-     static instance of CommonsHttpSolrServer per solr server url and share it for all requests.
+     static instance of HttpSolrServer per solr server url and share it for all requests.
      See https://issues.apache.org/jira/browse/SOLR-861 for more details
    */
-   SolrServer server = new CommonsHttpSolrServer( url );
+   SolrServer server = new HttpSolrServer( url );
  }}}
  
  
  == Changing other Connection Settings ==
- !CommonsHttpSolrServer allows setting connection properties.
+ !HttpSolrServer allows setting connection properties.
  
  {{{
    String url = "http://localhost:8983/solr"
-   CommonsHttpSolrServer server = new CommonsHttpSolrServer( url );
+   HttpSolrServer server = new HttpSolrServer( url );
    server.setSoTimeout(1000);  // socket read timeout
    server.setConnectionTimeout(100);
    server.setDefaultMaxConnectionsPerHost(100);
@@ -144, +144 @@

  For simplicity, the most common commands are modeled in the [[http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/SolrServer.html|SolrServer]]:
  
  == Adding Data to Solr ==
-  * Get an instance of server first.  For a local server, use CommonsHttpSolrServer:
+  * Get an instance of server first.  For a local server, use HttpSolrServer:
  
  {{{
-     SolrServer server = new CommonsHttpSolrServer("http://HOST:8983/solr/");
+     SolrServer server = new HttpSolrServer("http://HOST:8983/solr/");
  }}}
  
   * To use a local, embedded server instead:
@@ -211, +211 @@

  This is the most optimal way of updating all your docs in one http request.
  
  {{{
- CommonsHttpSolrServer server = new CommonsHttpSolrServer();
+ HttpSolrServer server = new HttpSolrServer();
  Iterator<SolrInputDocument> iter = new Iterator<SolrInputDocument>(){
       public boolean hasNext() {
          boolean result ;
@@ -308, +308 @@

  import java.util.Collection;
  
  import org.apache.solr.client.solrj.SolrServerException;
- import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+ import org.apache.solr.client.solrj.impl.HttpSolrServer;
  import org.apache.solr.common.SolrInputDocument;
  
  public class Test
  {
      private static int fetchSize = 1000;
      private static String url = "http://localhost:8983/solr/core1/";
-     private static CommonsHttpSolrServer solrCore;
+     private static HttpSolrServer solrCore;
  
      public Test() throws MalformedURLException
      {
-     	 solrCore = new CommonsHttpSolrServer(url);
+     	 solrCore = new HttpSolrServer(url);
      }
  
      /**
@@ -544, +544 @@

  
  @Grab(group='org.apache.solr', module='solr-solrj', version='1.4.1')
  @Grab(group='org.slf4j', module='slf4j-jdk14', version='1.5.5')
- import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
+ import org.apache.solr.client.solrj.impl.HttpSolrServer
  import org.apache.solr.common.SolrInputDocument
  
  String url = "http://localhost:8983/solr"
- def server = new CommonsHttpSolrServer( url );
+ def server = new HttpSolrServer( url );
  
  def doc = new SolrInputDocument()
  

Mime
View raw message