Search code examples
google-cloud-firestoregoogle-cloud-functionsalgolia

Doing relationship searches with Algolia?


I have Google Firestore + Google Functions connected with Algolia.

I know you can do one query from 2 indexes at the same time.

But how can I filter the query based on criteria from 2 indexes? (meaning not to filter 2 results from 2 indexes but filter results from 1 index based on criteria from 2 indexes)

This is a representation of my structure:

products:

{
 objectID: '543j5kh43k5',
 name: 'tomatto',
 storeID: 'kj54h3jk45'
}

stores:

{
 objectID: 'kj54h3jk45',
 name: 'Walmart',
 geoHash: "9zvxepu69x",
 lat: 44.95515049999999,
 lng: -93.37788669999999
}

I want to be able to do a query that would filter out products based on the product name and store location.

If I can't do this with Algolia, maybe I can do this with Google Cloud Functions?

Any ideas?


Solution

  • Algolia wasn't a solution for me as Algolia requires all of your data (that you would like to use for searching) to be on the same collection when indexing.

    I've moved to elastic search, with it, there is a possibility to transform reference IDs to actual data while indexing.

    Setup tutorial: https://medium.com/@acupofjose/wondering-how-to-get-elasticsearch-and-firebases-firestore-to-play-nice-1d84553aa280

    Library: https://github.com/acupofjose/elasticstore