Is it possible to query multiple fields in a firestore document for the same value?
Imagine I have numerous documents where each described a sport:
sportsRef.collection("sports").documents [
["bowling" : [
"equipment": "bowling ball, bowling alley, bowling shoes",
"description": "bowl the ball" ]]
["football": [
"equipment": "ball, boots, shin pads, goalie gloves",
"description": "kick the ball in the goal" ]]
["darts": [
"equipment": "darts, dartboard",
"description": "throw the dart at the board" ]]
["boxing": [
"equipment": "boxing gloves, ring",
"description": "punch your contender" ]]
["shot put": [
"equipment": "shot put",
"description": "throw the shot put, looks like a ball" ]]
]
Is there any way to make a query that, if I searched for a value of "ball", would return all the documents that have "ball" within their values. So in this case I would be returned bowling, football and shot put ("ball" is in the description of shot put).
The reason why I ask is because I have implemented a UISearchController in my iOS app and am trying to do the search in my Firestore by constructing a query in my app.
Firestore doesn't support substring, regular expression, or full text search types of queries. Those kind of searches don't scale with the way Firestore manages its indexes.
If you need fully text searching, consider duplicating your data into a search engine such as Algolia. This type of solution is discussed in the Firebase docs.