How do I add GeoSearch to my Index with Firebase

If this is true:

The code in this example shows you how to sync one, 1-child deep node of your Firebase tree. It does not automatically index an entire nested Firebase database.

From: Here

How am I supposed the get the _geoloc Branch within my Firebase Objects?

My code:

exports.indexentry = functions.database
  .ref('/businessSearch/{uid}/')
  .onWrite(event => {
    const index = client.initIndex(ALGOLIA_POSTS_INDEX_NAME);
    const firebaseObject = Object.assign({}, event.data.val(), {
      objectID: event.params.uid,
    });
    index.saveObject(firebaseObject); // .then or .catch as well
  });

Hello Ethan!

There has been some discussions around that in the forum, especially here and to some extent here. Can you check them (especially the first one) and see if they can help you with syncing your nested _geoloc branch? :slight_smile:

These don’t help me.

Okay, can you please show me the schema for how you’re storing your data on Firebase? where/how are the lat and lng stored?

Also, by searching online on stackoverflow, there are many answers that I could find around how to handle nested child nodes in Firebase. But I would need more info from your side in order to guide you in the right direction.

Here’s how my Firebase is organized:

Would I use something like this?

index.partialUpdateObject({
  _tags: {
    value: 'MyTag',
    _operation: 'Add'
  },
  objectID: 'myID'
}, function(err, content) {
  console.log(content);
});

I found this code in the Under the JS Docs here

UPDATE

This seems to just be a timing issue whenever the business is added to the database. Whenever I added another value under _geoloc the lat: and lng: were indexed
Sorry for the confusion

Glad to hear you were able to solve it! Let us know if you have more questions :slight_smile: