I have a small website running on Java with probably a dozen of markdown files. I want to provide a full text search for user to quickly access those markdown files. Since it is small I can afford building up the index in memory each time the web app is started. Any suggestion?
Note
I would like to stay away from any database solution, sql or nosql.
I prefer the solution is provided as a library rather than builting into an XX framework
To implement a full-text search in a SQL database, you must create a full-text index on each column you want to be indexed. In MySQL, this would be done with the FULLTEXT keyword. Then you will be able to query the database using MATCH and AGAINST.
SQL Server databases are full-text enabled by default. Before you can run full-text queries, however, you must create a full text catalog and create a full-text index on the tables or indexed views you want to search.
How can I tell if Full-Text Search is enabled on my SQL Server instance? A: You can determine if Full-Text Search is installed by querying the FULLTEXTSERVICEPROPERTY like you can see in the following query. If the query returns 1 then Full-Text Search is enabled.
A full-text search is a comprehensive search method that compares every word of the search request against every word within the document or database.
Use one of the in-memory databases, either H2 or HSQLDB. Then, for the full text search part, just use Hibernate Search. It will work with either of the two DBs and it will keep you from having to deal with Lucene at all: you can just annotate your entities, and go: all the indexing will happen automatically, and if you want to do things like boost fields, you can do that with a simple annotation.
As a side project I have implemented a simple in memory text search solution for java.
https://github.com/bradforj287/SimpleTextSearch
Key Features:
Might want to take a look.
Drop in Apache Lucene, the more-or-less gold standard in full-text search. It is happy to operate in memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With