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

前端 未结 16 1567
抹茶落季
抹茶落季 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:34

    There's no such operator, allowed ones are ==, <, <=, >, >=.

    You can filter by prefixes only, for example for everything that starts between bar and foo you can use

    collectionRef.where('name', '>=', 'bar').where('name', '<=', 'foo')

    You can use external service like Algolia or ElasticSearch for that.

提交回复
热议问题