0

It is necessary to filter the data by name, which contains the text written in the input. enter image description here

For example, in an input I write ann and I get all the names containing this. I get this error enter image description here How can I fix this and is there a function in firebase that searching in a string, not in an array?

const Search = () => {
    const userList = collection(db, 'users');
    const [result, setResult] = useState([]);

    const searchUser = async(e) => {
        let txt = e.target.value;
        const items = await getDocs(query(userList, where('name', 'in', txt)));
        await setResult(items.docs.map((doc) =>
            ({...doc.data()})
        ))
    }

    return <>
      
    </>
}
export default Search;

Thank you.

Andrey
  • 63
  • 6
  • Firestore doesn't have built in support for partial string matches (other than `>=` and `<=`). To do that you mostly need to use external search services such as Algolia, Elastic Search, or Typesense. – Nicholas Tower Jan 19 '23 at 11:14

0 Answers0