0

I am trying to upload my Firebase data to Algolia. I am using the example script in Algolia site. This script successfully works for months. But today, I cannot upload my data. The script as follows:

var algoliasearch = require('algoliasearch');
var client = algoliasearch("******", "********");
var index = client.initIndex('restaurants');
// Connect to our Firebase contacts data
var firebase = require('firebase');
var config = {
  apiKey: "*******",
  authDomain: "******",
  databaseURL: "******"
};

firebase.initializeApp(config);

var fb = firebase.database().ref('restaurants');

fb.on('value', initIndex);
function initIndex(dataSnapshot) {
  // Array of data to index
  var objectsToIndex = [];
  // Get all objects
  var values = dataSnapshot.val();
  // Process each Firebase ojbect
  for (var key in values) {
    if (values.hasOwnProperty(key)) {
      // Get current Firebase object
      var firebaseObject = values[key];
      // Specify Algolia's objectID using the Firebase object key
      firebaseObject.objectID = key;
      console.log(key);
      // Add object for indexing
      objectsToIndex.push(firebaseObject);
    }
  }
  // Add or update new objects
  index.saveObjects(objectsToIndex, function(err, content) {
    if (err) {
      throw err;
    }
    console.log('Firebase Algolia import done');
  });
}
starrystar
  • 668
  • 3
  • 8
  • 22

1 Answers1

0

I think data size is the problem. Because when I export my data as json. In the algolia console, I cannot upload the data because of the size. When I partially upload my data, the scripts work and indexes are uploaded.

starrystar
  • 668
  • 3
  • 8
  • 22