J
J
Jay Orson2015-05-10 19:51:05
MySQL
Jay Orson, 2015-05-10 19:51:05

What is the best way to organize full-text search in MySQL?

There is a table with a list of urls with type text (the number of characters is not known in advance)

CREATE TABLE `mytable` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `list_of_url` TEXT,
  PRIMARY KEY (`id`),
  FULLTEXT (`list_of_url`)
)  ENGINE = MyISAM

The number of lines can be very large (on the order of hundreds of thousands). All urls must be unique. And since the selection by url will be done very often, it makes sense to optimize queries. The search will be carried out not by a part of the string, but by a complete match.
Found, it seems, the only way for full-text search:
Query, like
SELECT id, MATCH (list_of_url) AGAINST ('/index.php?id=123&edit=1') FROM mytable

returns, if understood correctly, the relevance value.
Does it make sense to use a query like:
SELECT * FROM `mytable` WHERE `list_of_url` LIKE '/index.php?id=123&edit=1'

using a fulltext index, or is there a way to organize such a search in a different, more elegant way?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2015-05-10
@JayOrson

Normalize the table, store each url in a separate entry, then the search will be simple in comparison and as fast as possible.

P
Puma Thailand, 2015-05-10
@opium

Why full text search?
You do a regular index on the field and then in the query the usual comparison url='your string'

M
Melkij, 2015-05-10
@melkij

Regular b-tree index. What the hell is fulltext? And text I doubt that's a good idea. Try with varchar.
The hash index will work well. True, mysql does not know how, you have to emulate through an additional field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question