I have a database of about 200 thousand books. I want to give my users the ability to quickly find a book by title. Now, some headings may have a prefix of type A, THE, etc., and may also have numbers in the title, so a search of 12 should match books with "12", "twelve" and "tens" in the title. This will work through AJAX, so I need to make the database query very fast.
I assume that most users will try to search using some header words, so I'm going to split all the headings into words and create a separate database table that will display the words in the headings. However, I am afraid that this may not give the best results. For example, the title of a book may be about 2 or 3 commonly used words, and I could get a list of books with longer headings that contain all 2-3 words and the one I'm looking for lost, like a needle in a haystack. In addition, searching for a book with many words in the title may slow down the query due to the large number of OR clauses.
Basically, I'm looking for a way:
- quickly find results.
- sort them by relevance.
I guess this is not the first time that someone needs something like this, and I would not want to reinvent the wheel.
PS I am currently using MySQL, but if necessary I could switch to something else.
algorithm search
Milan Babuลกkov
source share