Implement a "Tag search"

Hey guys,

I’m stuck a bit in the moment and hope to find some help.

I do have some locations in my database which i wanna search fir based on “tags”. (Like show all Location which are “restaurant” or “bowling centers”)

I thought its a good idea to have a seperate table “Tags” containing all the tags. Then create a Relation Column inside the Location Class to assign all tags.

But i really have no idea how to query correctly for it. Is using arrays containing pointers a better approach?

Help would be great. :slight_smile:

These two solutions should work. I personally prefer to use the relation field instead of an array of pointers. The query on a relation field should be as easy as something like this:

const query = new Parse.Query('Location');
query.equalTo('tags', someTagObject);


1 Like

But this way we can query only one tag. What if that location is a giant shopping center which include restraunts, cinema and a barber?

I think with this way would be better.
You save location tags as array

JSONArray tags = new JSONArray();

Location location = new Location();

Then you do query with preferred tags

ParseQuery<Location> getposts = new ParseQuery<Location>(Location.class);

With this method you can get locations with multiple tags with one query.

1 Like

Hey, thanks for your reply!

Seems like a nice solution :slight_smile: - but is it “clever” to save the tags as strings directly in the array? Isn’t it better to save the objectId’s or Pointer Objects ?