I think you are missing a call to *add
<http://lucene.apache.org/solr/4_1_0/solr-solrj/org/apache/solr/client/solrj/SolrServer.html#add(java.util.Collection)>*
(Collection<http://download.oracle.com/javase/6/docs/api/java/util/Collection.html?is-external=true>
<SolrInputDocument<http://lucene.apache.org/solr/4_1_0/solr-solrj/org/apache/solr/common/SolrInputDocument.html>>
docs)
or one of the similar methods.

SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField( "id", 23);
doc1.addField( "title", "doc1" );
doc1.addField( "author","Chetan Bhagat" );
doc1.addField( "contents", "I am the best." );
doc1.addField( "date_modified", "12-12-2014" );
server.add(doc1);
server.commit();



On Sat, Dec 21, 2013 at 5:43 PM, Nutan <nutanshinde1...@gmail.com> wrote:

> i am trying to index documents with solrj, this is my code,
>
> import org.apache.solr.client.solrj.SolrServerException;
> import org.apache.solr.client.solrj.impl.*;
> import org.apache.solr.common.SolrInputDocument;
> import java.io.IOException;
>
> public class index {
>
> public static void main(String[] args) throws IOException,
> SolrServerException {
> String url = "http://localhost:8080/solr/document/";;
> HttpSolrServer server = new HttpSolrServer( url );
> server.setMaxRetries(1); // defaults to 0.  > 1 not recommended.
> server.setConnectionTimeout(5000);
> server.setSoTimeout(1000);  // socket read timeout
> server.setDefaultMaxConnectionsPerHost(100);
> server.setMaxTotalConnections(100);
> server.setFollowRedirects(false);  // defaults to false
> SolrInputDocument doc1 = new SolrInputDocument();
> doc1.addField( "id", 23);
> doc1.addField( "title", "doc1" );
> doc1.addField( "author","Chetan Bhagat" );
> doc1.addField( "contents", "I am the best." );
> doc1.addField( "date_modified", "12-12-2014" );
> server.commit();
> }
> }
> After running,(running as a java application) the console on eclipse shows
> this:
>
> Dec 21, 2013 2:07:25 AM org.apache.solr.client.solrj.impl.HttpClientUtil
> createClient INFO: Creating new http client,
> config:maxConnections=128&maxConnectionsPerHost=32&followRedirects=false
>
>
> My schema is:
> <schema  name="documents">
> <fields>
>
> <field name="doc_id" type="uuid" indexed="true" stored="true" default="NEW"
> multiValued="false"/>
> <field name="id" type="integer" indexed="true" stored="true"
> required="true"
> multiValued="false"/>
> <field name="contents" type="text" indexed="true" stored="true"
> multiValued="false"/>
> <field name="author" type="title_text" indexed="true" stored="true"
> multiValued="true"/>
> <field name="title" type="title_text" indexed="true" stored="true"/>
> <field name="date_modified" type="date" indexed="true" stored="true"
> multivalued="true"/>
> <field name="_version_" type="long" indexed="true" stored="true"
> multiValued="false"/>
> <dynamicField name="ignored_*" type="text" indexed="true" stored="true"
> multiValued="true"/>
>
> <field name="spelltext" type="spell" indexed="true" stored="false"
> multiValued="true" />
> <copyField source="contents" dest="spelltext" />
>
> <field name="description_ngram" type="text_ngram" indexed="true"
> stored="false" />
> <copyField source="contents" dest="description_ngram" />
> <field name="title_autocomplete" type="lowercase" indexed="true"
> stored="true" />
> <copyField source="title" dest="title_autocomplete" />
> </fields>
>
> Logs does not show any error.Am i following the right process?
> What causes this abnormal termination??
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/program-termination-in-solrj-tp4107706.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Regards,
Manish

Reply via email to