I’m trying to create a search engine for our library. Currently I have table call book_tittle where the column contain:
id (int)
book_tittle (varchar 256)
book_description (varchar 256)
author_id
When someone search book title, for example he type: “big bird”, I simply search from table where book_title like '%big bird%'.
If I have a book titled “big bird fly” this simple query was enough, but unfortunately when I have a book titled “big blue bird”, the query will return nothing.
Can someone suggest me how to solve it? So that if someone search for “big bird”, he will get “big bird fly” book and “big blue bird” book.
If you modify your field to a TEXT field instead of VARCHAR, you can use a FULLTEXT index. Then, you can use MATCH instead of LIKE to match a string. This match is much more flexible. You can match for
big birdto match the wordsbigandbirdor you can match for"big bird"if you want to match the words together. You can also use wildcards, likebir*to matchbirdandbirth.