Best way to implement hashtags?


I am making a social app and would like to search content through hashtags. As far as I can understand I have two options:

  1. search for the included hashtags in the content caption string (fulltext search)
  2. create entity “Hashtag” and a relation to the content (entity “Post”)

Here are the problems:

  1. fulltext search will be slow once I get a lot of content
  2. relations are retrieved in an array - what if I have like thousands of posts labeled with the same hashtag?

Thanks for advice!

Hi Miroslav,

You will have to retrieve the Posts with parent relation Hashtag having some value you need. This way the Posts will be retrieved in pages.

that is what I thought I can do, but when I fetch the Hashtag, the posts (one-to-many) relation is really only an array and I cannot have that paginated. I believe you know something that I don’t. Can you describe your solution in more detail?

Thank you.

No, I mean you need to fetch Posts, not Hashtags. And use the following whereClause:

Hashtag[post].name = 'xxx'

wow, great thanks Sergey!