V
V
Vadim2021-07-17 18:58:15
MySQL
Vadim, 2021-07-17 18:58:15

What is the best way to organize storage and relevant search across multiple tags?

There is a storage base for entities (documents, an image is not the essence), each entity has a certain set of tags. For example,
doc1 - tag1
doc2 - tag2
doc3 - tag3, tag4
doc4 - tag1, tag2, tag3 Entities

are expected to be several million, unique tags are expected to be several hundred (perhaps thousands).

It is necessary to organize storage and search by tags in such a way, taking into account the following conditions:
- display in the search results if at least 1 tag matches
- the more tags match, the higher the entity should be in the search results
- you need to paginate the result

For example, if a search is specified "tag1 tag3 tag5" then the result should be
doc4
doc1
doc3

Of course, the first thing that suggests itself is the organization of many-to-many storage with an intermediate table. But I can't figure out how to get the desired result with minimal cost. Perhaps you should look towards Sphinx or Elasticsearch, but you don’t really want to raise additional software.

Maybe someone will have some ideas, advice?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question