3

I've seen several statements online to the effect that NHibernate (or Hibernate) Search "takes care of the database/index synchronization".

When I read these statements, I cannot help but wonder if there is an implied "...as long as you use [N]Hibernate for any and all data access."

I am using NHibernate as a read-only data access layer against a database that is owned entirely by a different application - so my application will never be directly aware of external writes.

Does Hibernate/NHibernate Search actually do anything to monitor changes to the raw data, as in setting up a query notification and/or employing a time-to-live or "expiration" on whole or partial indexes?

Or is the Lucene index just going to get progressively staler over time as more and more rows are changed by external applications?

If this tool doesn't do that kind of synchronization, then aside from manual reindexing (which would be very difficult to time properly), is there anything else I can do to keep the Lucene index in sync with the database, or am I better off just using the Fulltext capabilities in SQL Server, as I have been doing up until this point?

Aaronaught
  • 120,909
  • 25
  • 266
  • 342

1 Answers1

1

I think I've been able to infer the answer from the Hibernate Search Documentation:

Hibernate Search will transparently index every entity persisted, updated or removed through Hibernate Core. However, you have to create an initial Lucene index for the data already present in your database.

If you have to create an initial index then it stands to reason that you'll also have to update that index if any changes are made outside the application.

Evidently, HS/NHS is not a fire-and-forget solution like SQL Server FTS, Oracle Text, etc., unless pretty much all data writes are done through the session.

Aaronaught
  • 120,909
  • 25
  • 266
  • 342
  • I'd also add that considering this limitation, along with NH Search's painful lack of mass-indexing capability (unlike the relatively full-featured Java/Hibernate version), I don't think I'd ever use NH search with a legacy database and would think long and hard before using it in a production application that might need to interop. – Aaronaught Jan 25 '12 at 13:37