abhish_gl
abhish_gl

Reputation: 401

DSE solr 3.2.5 : unable to insert a document using solrj java api

I am trying to insert a doc into a solr core.

code to insert doc

  public void addDocs(){
    // do not include '#' as a part of url
    String url = "http://localhost:8983/solr/moviedata.movie_rating";

    SolrClient solrclient = new HttpSolrClient(url);
    SolrInputDocument doc1 = new SolrInputDocument();
    doc1.addField("movieid", 1535);
    doc1.addField("avgrating", 4);
    doc1.addField("name", "some movie");

    Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
    docs.add(doc1);
    try {
         // solrclient.add(doc1); // adding single doc also throws same exception
         solrclient.add(docs);
         solrclient.commit();

    } catch (SolrServerException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

I am getting error:

Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:   
    Error from server at http://localhost:8983/solr/moviedata.movie_rating:
      Insert command failed after 4 attempts, source exception follows.

at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:558)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:214)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:210)
at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:117)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:103)

I tried to increase the write timeout interval in cassandra.yaml but it didnt help.

Upvotes: 0

Views: 391

Answers (1)

Thierry Templier
Thierry Templier

Reputation: 202286

My first thought is that you shouldn't directly insert data into Solr when using DSE. It's better to insert data into a Cassandra table and let's the tool do the synchronization with Solr.

That said, I think that you should have a more precise error in the stacktrace (a root cause). The error you provide is a bit general and it's difficult to answer only with it. Could you give us more details about the impacted elements in both Cassandra and Solr (extracts from schema.xml and Cassandra create table)? Thanks!

Hope it helps, Thierry

Upvotes: 1

Related Questions