1

I have some document in firebase like:

{name:'hasaduzzaman'}
{name:'himel'}

and I have firebase query like:

const [searchtext,setSearchText] = useState('')
let collectionRef = firestore.collection('users');
collectionRef.where('name', '==', searchText) // This is comming from the state of react hooks

My main point is if the searchText doesn't match the whole name of the user it doesn't return anything. Is there any way to use the where key without matching the full name of the user

  • 1
    Firestore can't perform full-text searches. It can do so-called **prefix** searches, where it returns documents where the name *starts with** a certain substring, by doing: `collectionRef.where('name', ">=", "him").where('name', "<", "hin")`. If you need more elaborate searching, consider another/additional solution for that. – Frank van Puffelen Apr 02 '21 at 14:53

1 Answers1

1

In case of firebase, this is not available. I had a similar concern,but created a workaround by using tags. In your case you can use algolia service I guess

Even they have an official docs regarding the same

firestore algolia docs

HexaCrop
  • 3,863
  • 2
  • 23
  • 50