1

I am trying to query data in FB/FS.

Lets say I have data like this:

"items": {
    "id1":{
        "phrase": "the cat got hit by a van"
    }
    "id2":{
        "phrase": "the frog got hit by a bad driver"
    }
    "id3":{
        "phrase": "the dog got hit by a car"
    }
    "id4":{
        "phrase": "the deer got hit by a bus"
    }
}

If I wanted to query data where phrase contains "cat" or "dog || van", how would I do this? Or can it be done?

I tried

db.collection("items").where("phrase", "array-contains", urlParams.get('s')).get().then((querySnapshot) => { ... }

but phrase is not an array, its a string.

0

1 Answer 1

1

This is not possible in Firebase - see this link

Your options are really to either change your data structure to make use of Firebase features, query the entire collection by retrieving all documents and searching through them client side (which can very quickly become very expensive), or to switch to a different database solution - potentially something SQL based is what you are looking for.

Sign up to request clarification or add additional context in comments.

1 Comment

was afraid of this. thanks for the quick response.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.