Firestore是否支持基于5个范围过滤器的单个where查询?

huangapple go评论49阅读模式
英文:

Can Firestore support a single where query based on 5 between filters

问题

我想知道如果Firestore中有10K条记录的集合,是否能支持带有5个范围过滤器的查询。例如:

其中(field_1 >= min_a and field_1 <= max_a)并且
      (field_2 >= min_b and field_2 <= max_b)并且
      (field_3 >= min_c and field_3 <= max_c)并且
      (field_4 >= min_d and field_4 <= max_d)并且
      (field_5 >= min_e and field_5 <= max_e)

我会遇到索引或查询限制吗?

英文:

I would like to know if a firestore collection of 10K records can support a query with 5 between filters. Eg.

Where (field_1 >= min_a and field_1 <= max_a) and
      (field_2 >= min_b and field_2 <= max_b) and
      (field_3 >= min_c and field_3 <= max_c) and
      (field_4 >= min_d and field_4 <= max_d) and
      (field_5 >= min_e and field_5 <= max_e) 

Will I run into and index or query limitations?

答案1

得分: 2

更新:我忽略了你是在对不同字段执行范围条件。文档中指出不支持这样做。


由于你只有AND子句,不应该会遇到任何限制。你需要有一个匹配所有字段的索引,但如果必要的索引缺失,SDK会抛出错误。

请查看文档以获取有关Firestore查询功能的限制的列表。

英文:

Update: I had missed that you're performing the range conditions on different fields. That is not supported, as shown in the documentation I linked.


Since you only have AND clauses you should not be hitting any limits. You will need to have an index that matches all the fields though, but the SDKs will raise an error if the necessary index is missing.

See the documentation for a list of the limitations on Firestore's query capabilities

答案2

得分: 2

显然这是不可能的。文档指出:“在复合查询中,范围(<,<=,>,>=)和不相等(!=,not-in)比较必须全部在同一字段上进行过滤。”

英文:

Apparently this isn't possible. The docs states

In a compound query, range (<, <=, >, >=) and not equals (!=, not-in) comparisons must all filter on the same field.

huangapple
  • 本文由 发表于 2023年4月19日 23:51:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056525.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定