You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2011/09/25 07:00:18 UTC

[Solr Wiki] Update of "Solrj" by RonKuris

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 RonKuris:
http://wiki.apache.org/solr/Solrj?action=diff&rev1=62&rev2=63

Comment:
Added required argument to CommonsHttpSolrServer in example

  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
+  * Get an instance of server first.  For a local server, use CommonsHttpSolrServer:
  
  {{{
+     SolrServer server = new CommonsHttpSolrServer("http://HOST:8983/solr/");
+ }}}
+ 
+  * To use a local, embedded server instead:
+ 
+ {{{
-     SolrServer server = getSolrServer();
+     SolrServer server = new EmbeddedSolrServer();
  }}}
- The `getSolrServer()` method body can be as follows if you use a remote server,
+  * If you wish to delete all the data from the index, do this
  
  {{{
- public SolrServer getSolrServer(){
-     //the instance can be reused
-     return new CommonsHttpSolrServer();
- }
- }}}
- if it is a local server use the following,
- 
- {{{
- public SolrServer getSolrServer(){
-     //the instance can be reused
-     return new EmbeddedSolrServer();
- }
- }}}
-  * If you wish to clean up the index  before adding data do this
- 
- {{{
-     server.deleteByQuery( "*:*" );// delete everything!
+     server.deleteByQuery( "*:*" );// CAUTION: deletes everything!
  }}}
   * Construct a document