Why does firestore not work with multiple field ra

2019-08-18 04:48发布

Why does firestore not work with multiple field range filters?

I also want to know why I can not do full text search.

Is there a reason for the algorithm?

I want to know the reason.

1条回答
Root(大扎)
2楼-- · 2019-08-18 05:13

Firestore has a quite unique performance guarantee: the time it takes to retrieve data only depends on the amount of data you retrieve, not on the amount of data you retrieve it from. So no matter if there are a thousand, a million, or a billion documents in a collection, retrieving ten of those documents will always take the same amount of time.

In order to be able to guarantee this performance, Firestore has a limited set of (mostly query) capabilities. For example: Firestore only supports queries for which it can jump to the correct starting point in an index, and stream results from that starting point until the end of the query. This precludes it from supporting things like:

  • OR queries, since those would require skipping through the index, which would make it impossible to guarantee the performance. Note that work is under way to support a subset of possible IN queries, so that you could query for something like "give me all restaurants that serve either Thai or Italian food".
  • queries for substring of text. Firestore only supports so-called prefix queries, so where the value starts with a substring, but not where the value contains a substring. So you could search for "give me all names that start with 'zla'", but not for "give me all names that contain 'lat'".
  • querying on multiple ranges, since those too might make it impossible to guarantee the performance.

For another good explanation of this, see the Getting to know Cloud Firestore episode on queries.

查看更多
登录 后发表回答