I’m building a WebService (CXF with Spring and JPA) to search a read-only database table, i.e., a table which is in a database I only have read permissions, I must not change anything there.
I need to implement a full-text search for some fields of this table, and querying it is too slow (it is a books database, with title, author and keywords for each book) so I need to build an index for it.
I’m trying to understand if Hibernate Search help me with that, and how I could go about it.
I think it can’t cause the documentation says it builds the index when the entities are updated (which are never the case in my WebService). But I’m new to all of its terminology, so I can misinterpreting things.
What would be a good path to go about this?
What should I study first to understand better what I need to do?
Thanks in advance!
I think Hibernate Search can be a perfect fit for your problem, because it allows you to build/keep the index on the file system. This way the database stays untouched. Given that you are already using JPA it should be extremely easy to enable Hibernate Search. You basically just need to get the Hibernate Search jar file and add it to your project, then annotate the entities you want to have indexed with @Indexed and the fields you want to index with @Field. Of course that’s very simplified, but the online documentation should help you out there. There is a getting started section which explain the basics. Once you get this, you can dive deeper into different analyzers etc – http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/
Well, Search will help you via automatic index updates to keep your index and database in sync for read/write application. However, Search also has a programmatic API for creating an initial index or manually rebuild the index whenever you see fit. There are several ways to do that, but it can be as simple as:
Again, the documentation has more examples. I recommend you follow the getting started examples and follow up with concrete questions/problems you encounter.