Return-Path: X-Original-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3AD13DCFD for ; Thu, 15 Nov 2012 21:10:37 +0000 (UTC) Received: (qmail 19810 invoked by uid 500); 15 Nov 2012 21:10:37 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 19780 invoked by uid 500); 15 Nov 2012 21:10:37 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 19773 invoked by uid 99); 15 Nov 2012 21:10:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Nov 2012 21:10:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Nov 2012 21:10:33 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 8F174B7E; Thu, 15 Nov 2012 21:10:12 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Thu, 15 Nov 2012 21:10:11 -0000 Message-ID: <20121115211011.22035.55378@eos.apache.org> Subject: =?utf-8?q?=5BSolr_Wiki=5D_Update_of_=22Solrj=22_by_davidschorr?= Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for chan= ge notification. The "Solrj" page has been changed by davidschorr: http://wiki.apache.org/solr/Solrj?action=3Ddiff&rev1=3D66&rev2=3D67 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 Il= legalAccessError 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#Ille= galAccessError|slf4j FAQ]]. = - =3D CommonsHttpSolrServer =3D + =3D HttpSolrServer =3D - The [[http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl= /CommonsHttpSolrServer.html|CommonsHttpSolrServer]] uses the [[http://jakar= ta.apache.org/httpcomponents/httpclient-3.x/|Apache Commons HTTP Client]] t= o 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 s= olr. Note: CommonsHttpSolrServer was changed to HttpSolrServer and Stream= ingUpdateSolrServer is now ConcurrentUpdateSolrServer as of solr 4.0. = {{{ String url =3D "http://localhost:8983/solr"; /* - CommonsHttpSolrServer is thread-safe and if you are using the followi= ng constructor, + HttpSolrServer is thread-safe and if you are using the following cons= tructor, you *MUST* re-use the same instance for all requests. If instances a= re 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 shar= e it for all requests. + static instance of HttpSolrServer per solr server url and share it fo= r all requests. See https://issues.apache.org/jira/browse/SOLR-861 for more details */ - SolrServer server =3D new CommonsHttpSolrServer( url ); + SolrServer server =3D new HttpSolrServer( url ); }}} = = =3D=3D Changing other Connection Settings =3D=3D - !CommonsHttpSolrServer allows setting connection properties. + !HttpSolrServer allows setting connection properties. = {{{ String url =3D "http://localhost:8983/solr" - CommonsHttpSolrServer server =3D new CommonsHttpSolrServer( url ); + HttpSolrServer server =3D 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://luce= ne.apache.org/solr/api/org/apache/solr/client/solrj/SolrServer.html|SolrSer= ver]]: = =3D=3D Adding Data to Solr =3D=3D - * Get an instance of server first. For a local server, use CommonsHttpS= olrServer: + * Get an instance of server first. For a local server, use HttpSolrServ= er: = {{{ - SolrServer server =3D new CommonsHttpSolrServer("http://HOST:8983/sol= r/"); + SolrServer server =3D 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 reques= t. = {{{ - CommonsHttpSolrServer server =3D new CommonsHttpSolrServer(); + HttpSolrServer server =3D new HttpSolrServer(); Iterator iter =3D new Iterator(){ 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 =3D 1000; private static String url =3D "http://localhost:8983/solr/core1/"; - private static CommonsHttpSolrServer solrCore; + private static HttpSolrServer solrCore; = public Test() throws MalformedURLException { - solrCore =3D new CommonsHttpSolrServer(url); + solrCore =3D new HttpSolrServer(url); } = /** @@ -544, +544 @@ = @Grab(group=3D'org.apache.solr', module=3D'solr-solrj', version=3D'1.4.1') @Grab(group=3D'org.slf4j', module=3D'slf4j-jdk14', version=3D'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 =3D "http://localhost:8983/solr" - def server =3D new CommonsHttpSolrServer( url ); + def server =3D new HttpSolrServer( url ); = def doc =3D new SolrInputDocument() =20