X
X
Xrist1An2015-04-13 19:50:55
MySQL
Xrist1An, 2015-04-13 19:50:55

MySQL search. Which of my options is the most rational?

When a user enters a search query, I parse it by words, and then I try to find a match from the database for each word. The question is how best to organize it.
There are three fields to search; title (there can be several words), color (only one word), category (only one word).
I have the following ideas:
- create another field, in which to drop all the information from 3 fields and search only for this, the 4th field, using FULLTEXT.
- Same thing, but search with LIKE
- Search 3 fields simultaneously with LIKE or FULLTEXT.
It seems to me that the first option is the most rational, but I'm not familiar with FULLTEXT. Will it be necessary to bring the data in this field to some kind of standard? Is it possible to just put all the text together with commas and other signs?
Thank you.
Ps Please do not offer the sphinx and others like it.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Andrey Mokhov, 2015-04-13
@mokhovcom

Use MySQL full-text search
For InnoDB tables, a full-text index is available from MySQL 5.6

D
Dmitry, 2015-04-13
@thewind

You need sphinx

A
Andrey, 2015-04-14
@andreyvlru

Sphinx is more sophisticated, but more difficult to configure and maintain;
in fact, an add-on specifically for full-text search.
If MySQL 5.6, then it's probably better to try the built-in full-text

A
Alexander, 2015-04-14
@wiggle

You can reduce the data in 1 field into a separate table, where the fields are id and search (CONCAT (title, color, category)) and search already in this table

V
Vadim Shandrinov, 2015-04-14
@suguby

There is no indexing on LIKE, FULLTEXT allows indexing, but one index per table. So - your first option

создать еще одно поле, в которое скинуть всю информацию из 3ех полей 
и искать только по этому, 4-му полю, с помощью FULLTEXT

but the possibilities of FULLTEXT are very limited, the user needs to be able to make queries like + cow and so on - it's difficult for him. So all the same sphinx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question