Hello dear users. I have a small request for you: Can you please tell me how to make hash tags on my website like on Twitter or VK?

  • one
    LIKE ? For fts? Why do you recommend this? All normal people build indexes and get their search for O(1) . - drdaeman Nov.
  • @drdaemon, What is [FTS] ( en.wikipedia.org/wiki/FTS )? Full Text Search or File Transfer System? Me for self-education. - ReinRaus 5:58
  • where does file transfer system?) - Gorets
  • @gorets well, the rest of the wiki abbreviations are poorly suited :) These two are the closest to the topic, just if it meant the first, then it would be more appropriate not "For FTS?" but "It's FTS!" - ReinRaus
  • Thanks, of course, but I would not be bothered by the code, I don’t understand coding, I’m mostly in layout, certainly not for free) - mandrovich

2 answers 2

When a publication is added (or edited), search for tags in its text. The simplest (but not always suitable) tool is regular regular expressions, searching for something in the spirit of /#(\w+)/ .

Finding tags write down the identifier of the publication in which they were found. As a result, if you present in the form of a table, you will have something in the spirit of:

 +---------------+------------------------------------+ | Тег | ID публикаций | +---------------+------------------------------------+ | теги | 167956, 165489, 148204 | | хэш | 167956, 147666 | +---------------+------------------------------------+ 

(For example, two real tags and several records with them from HashCode were taken).

In the case of relational databases, this can be represented, for example, by a table of the form:

 +---------------+-------------+ | tagname | post_id | +---------------+-------------+ | теги | 167956 | | хэш | 167956 | | теги | 165489 | ............................... 

When you need to search by tag or their intersection, simple work with sets is enough. Choose a set of identifiers for all records that contain (or do not contain) the necessary tags, and output these publications.

  • the response lacks information, how to convert the resulting tags into search links or something similar in the publication itself - Specter

I’ll add a little @drdaeman to the answer.

Well, about the conversion, it is still simple here!

If in the text @drdaeman wrote

The simplest (but not always suitable) tool is regular regular expressions, searching for something in the spirit of / # (\ w +) /.

Look for them in the text and highlight. (How to highlight, but somehow, how the soul will fall.)

Well, the search links are processed in the same way as regular tags, but probably just at a different address.

We found a hashtag # lab he will have a link of about this content

<a href = "/ hashtag / # laboratory"> # laboratory <\ a>

Well, at the address / hashtag / we process the resulting hashtag.


You can see how it is done on HASHKODE

 <а rel="nofollow" href="/users/2694/drdaeman"> @drdaeman <\a>