I have a MySQL table containing book chapters.
Table: book_chapter -------------------------- | id | book_id | content | --------------------------
Currently, I can search for content in full-text search, for example:
SELECT * FROM book_chapter WHERE book_chapter.book_id="2" AND MATCH (book_chapter.content) AGAINST ("unicorn hair" IN BOOLEAN MODE)
However, I would like to know if it is possible to search for content and return results in 30 pieces of characters so that the user can feel the gist. So, for example, if I search for “unicorn hair”, I will have this result:
------------------------------------------------- | id | book_id | content | ------------------------------------------------- | 15 | 2 | it isn't unicorn hair. You kno | ------------------------------------------------- | 15 | 2 | chup and unicorn hair in soup | ------------------------------------------------- | 27 | 2 | , should unicorn hair be used | ------------------------------------------------- | 31 | 2 | eware of unicorn hair for bal |
Please note that there are two results from the same record. Is it also possible?
Samin source share