Google Firestore: Query on substring of a property value (text search)

前端 未结 16 1681
抹茶落季
抹茶落季 2020-11-22 12:08

I am looking to add a simple search field, would like to use something like

collectionRef.where(\'name\', \'contains\', \'searchTerm\')

I tried

16条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 12:36

    I actually think the best solution to do this within Firestore is to put all substrings in an array, and just do an array_contains query. This allows you to do substring matching. A bit overkill to store all substrings but if your search terms are short it's very very reasonable.

提交回复
热议问题