This is a small guide on how to get database-specific full text search working on Spring JPA. Before you proceed, make sure you actually need full text search. Full text search is about matching words against words, not partial words against words, so depending on your use case, a simple like %data%
operator can be a better user experience.
As an example, if your dataset looks like this:
id | name
------------------
0 | reimu hakurei
1 | suwako moriya
If you search using FTS for hakurei
then you will find one result, however if you search for haku
instead (a partial word), then your query will return no results.
# select count(*) from touhou where fts(name, 'hakurei');
1
# select count(*) from touhou where fts(name, 'haku');
0
If however, you need word search on your dataset, this solution is usually easier and uses less resources than duplicating your entire dataset into Lucene/ElasticSearch/MeiliSearch.
This solution is also not database agnostic, so you will need a different configuration if you are running postgres/mariadb/etc..