Firestore Query Across Multiple Fields for Same Value

前端 未结 2 592
孤城傲影
孤城傲影 2021-01-16 09:45

Is it possible to query multiple fields in a firestore document for the same value?

Imagine I have numerous documents where each described a sport:

s         


        
相关标签:
2条回答
  • 2021-01-16 10:07

    One way to do something like that would be to restructure your data like so:

    ["bowling" : [
    "ball": true, "bowling alley": true, "bowling shoes": true,
    "description": "bowl the ball" ]]
    

    and then query for documents where "ball" is equal to true:

    Firestore.firestore().collection("sports").whereField("ball", isEqualTo: true)
    
    0 讨论(0)
  • 2021-01-16 10:19

    Firestore doesn't support substring, regular expression, or full text search types of queries. Those kind of searches don't scale with the way Firestore manages its indexes.

    If you need fully text searching, consider duplicating your data into a search engine such as Algolia. This type of solution is discussed in the Firebase docs.

    0 讨论(0)
提交回复
热议问题