[hibernate-dev] Interceptor question

Hardy Ferentschik hardy at hibernate.org
Fri May 11 12:15:48 EDT 2012

On May 11, 2012, at 6:07 PM, Sanne Grinovero wrote:

> I was expecting you to argue about it,


> and therefore I concede that
> some docs clarification at least is strongly required,

at the very least

> but I disagree on the expectations:
> I see a fundamental difference in behaviour expectations between
> a) "sync up database and index"
> b) "index Entries A and B now"
> In the first case it's up to Search to figure out what the correct set
> of data is, and this would obviously be defined by the conventional
> rules such as "all what's in the database", and implicitly by the
> filter.
> In the second case the user is explicitly demanding to index A and B;
> just think about the meaning of using #index .. it should never be
> needed if everything was perfectly in sync, so the intention of the
> method is clearly an explicit override.

It is needed (unless you use the mass indexer) to build an initial index or
rebuild an existing one. Also if I call #index I say "index this entity considering 
all the configuration which exists for this entity" (meaning the defined fields, but
also defined interceptors). How else can I rebuild the index for the blog example?

> Makes sense?


> Why would anyone use #index BTW ?

Fair point. However, atm we still offer both alternatives (mass indexer and explicit #index)
and I would argue they should behave the same way. See section 6.3. Rebuilding the whole index
in the docs.


> Sanne
> On 11 May 2012 16:54, Hardy Ferentschik <hardy at hibernate.org> wrote:
>> Really? I would argue differently.
>> Let's take the blog example where I only want to index blog entries which are
>> published. Adding the interceptor and relying on automatic indexing will not index un-published entries. Great.
>> If I, however, want/ have to re-index my blog entries via the API  the interceptor does not apply? Why?
>> IMO the interceptor has to apply for automatic index updates as well as explicit index request. Conceptually
>> (for a user) there is no difference between explicitly calling FulltextSession#index or auto-indexing. That's
>> exactly the type of confusion the user on the forum experienced.
>> I think we should change this behavior.
>> --Hardy
>> On May 11, 2012, at 5:23 PM, Sanne Grinovero wrote:
>>> As a user if I were asking to Search *explicitly* to index my entity,
>>> I would not be pleased in the framework to override my request... I
>>> think the code is correct, maybe it's worth pointing this out at least
>>> on #index() javadoc?
>>> Sanne
>>> On 11 May 2012 14:48, Hardy Ferentschik <hardy at ferentschik.de> wrote:
>>>> Hi,
>>>> quick question regarding the indexing interceptor. Why is WorkType.Index mapped to IndexingOverride.APPLY_DEFAULT -
>>>> https://github.com/hferentschik/hibernate-search/blob/master/hibernate-search-engine/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java#L132
>>>> Shouldn't it be the same as ADD? Am I missing something? I am asking, because of https://forum.hibernate.org/viewtopic.php?f=9&t=1015173
>>>> --Hardy

More information about the hibernate-dev mailing list