Quote:
(A) Can Hibernate Search cache search results?
Like, "iphone" is a popular product, so many users repeat the query "+product:iphone +manufacturer:apple" (query through a FullTextSession)...
It could be cached, if we assume all Lucene updates go through Hibernate-Search (so it knows when to invalidate the cache).
Yes, in several ways. The IndexReaders are reopened and keep the buffers of previous searches around even when opening a new IndexReader to be able to see fresh data, so if you repeat the same query the second time it will be much faster as the results are not directly cached but all other needed structures are.
It is also able to use the Hibernate Second level cache to load the entity values which are identified from the fulltext query (not cached directly).
In addition you can use filters, like in your example you could have a "manufacturer" filter and a "product" filter, both having a parameter which is going to be a key for the filter. Filters can be cached with several strategies, and this can of course be combined with the previously mentioned caches.
Quote:
(B) A related question, does Hibernate Search assume that no other process touches the Lucene Index?
Because I have an old home-made process that updates both the database and Lucene (keeping them consistent).
Can it run "side by side" with a newer Hibernate-Search based system? Of course disabling the 2nd level cache?
Yes that's possible. As you say you would need to disable second-level cache, and also you'll have to make sure the
exclusive_index_use option is set to
false.
When configuring it this way you'll be losing some of the performance benefits from the features I listed on A).
If you use Hibernate Search 4 all these options can be set differently on each index.