2

I am using node-solr-client for handling solr queries. I have written an update query as per the post here

Add and update data to Solr-4.3.0 using node module solr-client

My data is:

data = {
    'type_s':'applicant',
    'id': 5,
    'state_id':{'set':565656},
};

I have enabled autocommit to true

client = solr.createClient();
client.autoCommit = true;

When I run the code it gives me a response

{ responseHeader: { status: 0, QTime: 4 } }

Meaning it has been added to the index. But when I crosscheck using solr admin, I don't see the updates. Now when I run http://localhost:8983/solr/jobs/update?commit=true and check again then it is visible in solr admin.

Community
  • 1
  • 1
Jay Chakra
  • 1,481
  • 1
  • 13
  • 29

1 Answers1

3

Finally I got it working.

I just had to add a softcommit(). Here is the code.

data = {
    'type_s':'applicant',
    'id': 5,
    'state_id':{'set':565656},
};

client = solr.createClient();

//client.autoCommit = true;

client.add(data, function(err, obj) {
    if (err) {
      console.log(err.stack);
    } else {
      client.softCommit();
    }
  });
});

It just worked. I think the autoCommit option is not working or I am misconfiguring something.

Jay Chakra
  • 1,481
  • 1
  • 13
  • 29
  • 1
    Yep, I'd say the auoCommit option is either not working, or otherwise very mysterious. – Alex May 19 '21 at 11:44