首页 > 解决方案 > Firebase Firestore tie full-text search using external services with built in queries

问题描述

So, I know that in order to do full-text queries for Firestore data you have to use external services such as Algolia and Elasticsearch, which is fine. But my problem is that I don´t know how combine those with the existing querying tools of Firestore such as "where", "limit" and "startAfter".

Basically, I have a page where you can see the 10 most recent posts and then load 10 more by pressing a button and passing the value of the last element until you have reached the end. Like this tutorial >link< but without virtual scrolling.

query.where('active', '==', true).orderBy('createdAt').startAfter(offset).limit(10);

All of this works great, but by using an external service for the additional full-text search I have two different queries that don´t know about each other, defeating the purpose of Firestore´s attempt of providing pagination.

Do I miss something or is there already who has dealt with this problem?

标签: angularfirebaseelasticsearchgoogle-cloud-firestorealgolia

解决方案


The short answer is: you can't. Firestore queries can only consider data in Firestore documents, and nothing else.

If data is being mirrored to another database, that database will have to be queried separately. The code performing the queries can merge the results of multiple queries if needed.


推荐阅读