0

I have a small app where I need to query my firestore data. The query is a variable of a search string. It is working fine if the user enters in an exact match query. However, I need the user to be able to search a term LIKE what is in the data. Not just exact match.

Example Query: searchInput = "Exact Match Term"; querySnapshot = await firebase.firestore().collection('markers').where('title', '==', searchInput).get();

That will work only if the user enters in the title exactly as it shows in the data. I need it to pull anything like the search term. I have tried this and it does not pull any documents: searchInput = "PartialTerm"; querySnapshot = await firebase.firestore().collection('markers').where('title', 'array-contains', searchInput).get();

I changed '==' to 'array-contains' to avoid the exact match but now no records come in at all.

So, my question is how do I do a search query to the data where it will return all documents within my "markers" collection where the title is LIKE the searchInput from the user.

Thank you for helping me.

khtims75
  • 81
  • 1
  • 6
  • Firestore does not have an exact equivalent for SQL "like" queries, as they don't scale the way that Firestore requires. – Doug Stevenson Apr 08 '20 at 05:50
  • Your answer says to check the wrong documentation for the platform I am working on. I am working in React Native and the documentation is here, https://rnfirebase.io/ There is no mention of the solutions you speak of in this documentation. – khtims75 Apr 08 '20 at 15:04
  • The querying capabilities are the same for all client platforms. None of them support SQL LIKE. – Doug Stevenson Apr 08 '20 at 15:22

0 Answers0