Answer the question
In order to leave comments, you need to log in
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
Use MySQL full-text search
For InnoDB tables, a full-text index is available from MySQL 5.6
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
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
There is no indexing on LIKE, FULLTEXT allows indexing, but one index per table. So - your first option
создать еще одно поле, в которое скинуть всю информацию из 3ех полей
и искать только по этому, 4-му полю, с помощью FULLTEXT
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question