Java saveObject doing nothing

I’m running a bit of server code to update my algolia index. My code looks like this:

AsyncAPIClient client = new AsyncHttpAPIClientBuilder(ALGOLIA_APP_ID, ALGOLIA_ADMIN_KEY).build();
AsyncIndex<MyObject> index = client.initIndex("myIndex", MyObject.class);
} else {
    index.saveObject(myObjectID, myObject);

The code runs through fine. I’ve checked that it gets into both branches as expected. The deleteObject does exactly what it’s supposed to do (deletes the object from the index), but the saveObject does nothing. It throws no errors, just passes quietly through. No change to the index at all.

I’ve also tried index.partialUpdateObject(myObjectID, myObject) to no avail.

Extra note: I’m having the same problem in javascript. I can clear an index with index.deleteByQuery(’’), but nothing writes with index.saveObject(myObject).


The actions on algolia are asynchronous. Each action that modifies (deleteObject, saveObject, etc.) returns a Task. Then you can wait for the completion of this task. You can see it here:

Thanks! That fixed my Java problem. I implemented the same thing in my javascript, following the example in the documentation, but it didn’t work in that case. Is there something different with javascript?

Just curious, was this all because of a recent change in the Algolia API? Because I didn’t have problems writing a few days back with the same code.

Do you mean front-end javascript or Node.js?
For Node.js, the function to use is a bit different:
If you mean front-end javascript, we do not advise to send data from the front-end as anyone could modify your data, as the api key will be public.

There was no change on the Algolia API regarding this. Algolia is biased towards search. The indexing operations are a best effort operations. So if you need to have the data indexed you need to wait for the completion of the task.

Does this answer your question?

Sure, it answers the last question.

Yes, Node.js in the back end. And that documentation ( is what I had used.

But it still doesn’t work yet.

When I run the documentation code in my Node.js file,

index.addObject(myObject, function(err, content) {
  console.log('in addObject');
  index.waitTask(content.taskID, function(err) {
    console.log('in waitTask');
    if (!err) {
      console.log('object ' + content.objectID + ' indexed');

none of the log functions are ever executed, and nothing is written to my algolia index.

Any other suggestions?

It’s weird :confused:
Could you log index and addObject? So we could see if there is an issue elsewhere?

Also please use DEBUG=algoliasearch* node index.js and give us the results.

Logging index.addObject(myObject) without index.waitTask gives Promise { <pending> } and logging it with it gives undefined.

And here is the log for index, using the debug given by vvo,

Index {
  indexName: 'myIndex',
   AlgoliaSearchNodeJS {
     applicationID: 'APP_ID',
     apiKey: 'API_KEY',
     hosts: { read: [Object], write: [Object] },
     _timeouts: { connect: 2000, read: 5000, write: 30000 },
     _hostIndexes: { read: 0, write: 0 },
     _timeoutMultiplier: 1,
     _shuffleResult: [ 3, 1, 2 ],
     extraHeaders: [],
     cache: {},
     _ua: 'Algolia for Node.js 3.24.0',
     _useCache: false,
     _useFallback: true,
     _setTimeout: undefined,
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: [Object],
        keepAliveMsecs: 1000,
        keepAlive: true,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        maxCachedSessions: 100,
        _sessionCache: [Object] } },
  typeAheadArgs: null,
  typeAheadValueOption: null,
  cache: {} }
  algoliasearch:/1/indexes/myIndex request start +10ms
  algoliasearch:/1/indexes/myIndex method: POST, url:, headers: {"x-algolia-agent":"Algolia for Node.js 3.24.0","x-algolia-application-id":"APP_ID","x-algolia-api-key":"API_KEY"}, timeouts: NaN +0ms
  algoliasearch:/1/indexes/myIndex url:, method: POST, timeouts: {"connect":2000,"complete":30000} +1ms

Well, for now I moved it to a different environment and found a configuration that worked for what I was doing. Probably just an un-found bug in my original code. Thanks guys.

I am having a similar issue using Firebase Cloud Functions. I have the index.waitTask and it returns {“status”:“published”,“pendingTask”:false}. However, the algolia console shows the original object and never updates.