H
H
hckn2018-09-22 14:33:35
MongoDB
hckn, 2018-09-22 14:33:35

How to organize the search and storage of posts by hashtags?

An example on Twitter, when you put the # symbol, the site understands that this is a tag, highlights it with a link and searches for tweets that also contain this tag.
How to organize this using Mongo as an example?
The only thing that comes to mind is to parse for the presence of a hashtag at the stage of creating a tweet and save it in the same model. But then searching for posts by tags will be super slow and resource intensive. How then to do?
APD: in general, such an option: create a model for hashtags, and there add all the tweets that contain it. Hashtags will be in the index, the speed should be good (and then you can attach an elastic if necessary). Will it go?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2018-09-22
@lega

Add tags to an array inside the document and index it - you will quickly find documents by tag.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question