[hibernate-dev] Interceptor question

Sanne Grinovero sanne at hibernate.org
Fri May 11 12:34:20 EDT 2012


On 11 May 2012 17:15, Hardy Ferentschik <hardy at hibernate.org> wrote:
>
> 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

no doubt

>
>> 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?

Since the filter is user defined, based on the fact that the user
*knows* the blog needs to be indexed only when [businessrule],
it's not hard to adapt the code using an

if [businessrule] {
 fulltextSession#index( e );
}
else {
 log.discardBlogDRAFTFromIndex( e );
}

>
>> Makes sense?
>
> No
>
>> 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.

Maybe we shouldn't imply they are the same. Obviously the "old style"
provides far more control, this is just showcasing once more the
additional control the user has.

Let's put it the other way around: you want to use #purge( A ).
Why would you use the method? I guess because you want to remove
something from the index. And you want it to happen *now*, not start
to argue with the system ..

Would you expect Search to prevent you from doing that if the indexing
policy doesn't agree? And should it happen silently, or would you
expect an exception like
throw new SearchException( " HAHA we won't allow you to remove that!
No way! Go do your homework and implement a better filter strategy, or
go edit the index with an hex editor. No way we help you out!" )

;-)

Sanne

>
> --Hardy
>
>>
>> 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
>>>
>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev



More information about the hibernate-dev mailing list