I am currently creating an app where the administrator should be able to tag images. The visitors can search for a tag, and see the images that have that tag.
One image can have more than one tag. This represents how I currently have set up my data:
Images: {
PUSH_ID: {
url: "https://cdn.filestackcontent.com/o0ze07FlQjabT9nuteaE",
tags: {
PUSH_ID: {
tag: "1324"
},
PUSH_ID: {
tag: "4321"
}
}
}
}
When a visitor searches for a tag, I need to be able to query the tag, and find the URL of the images that have the given tag. I was thinking that something along the lines of this would work:
ref.orderByChild('tags/tag').equalTo(tag).once("value"...)
But after some reading I have come to the understanding that you can only query one level deep in Firebase.
If this is the case, I need to restructure my data, but I cannot figure out how it should be structured.
Can anyone help me?
Btw; I have been told that I should use something like Elasticsearch to query in Firebase, but this app is for an event with a limited ammount of traffic.
Thanks!