[hibernate-dev] HSearch: Using sharding and avoiding query on multiple shards

Sanne Grinovero sanne.grinovero at gmail.com
Wed Jun 3 13:27:24 EDT 2009

I am having a similar need in these days; this should be a very useful
feature, but I'd like more something I could use with the existing API

enableFullTextFilter( "MyShardsSelectionStrategy" ).setParameter( ... )

a practical example:
enableFullTextFilter( "LanguageFilter" ).setParameter( "IT-it" )

The existing IndexShardingStrategy should be able to be smarter and
have something like

DirectoryProvider<?>[] getDirectoryProvidersForQuery( filters && options )

So a smart ShardingStrategy could do some selections considering this.

I'm currently using sharding to shard my index on 25 different
languages (using per-language stemmers), so this would
be useful but I'd especially need to be able to "label" my different
DirectoryProviders using String identifiers,
I'd suggest to add a getName() to the DirectoryProvider interface: I
would use that to store countrycodes and
keep a map<String,DirectoryProvider> in my ShardingStrategy, so I can
easily select the right DP when
the LanguageFilter is enabled.

Another usage would be to shard an entity on an Enumerated property:
in this case an appropriate ShardingStrategy
could be provided by Search and auto-configured by reading the
possible enum values: that would be a very easy way
to enable sharding on an entity.


2009/6/3 Emmanuel Bernard <emmanuel at hibernate.org>:
> Begin forwarded message:
> From: chase.seibert+opensubscriber at gmail.com
> Date:  June 3, 2009 09:21:21  PDT
> To: emmanuel at hibernate.org
> Subject: Re: Re: [hibernate-dev] HSearch: Using sharding and avoiding query
> on multiple shards
> Reply-To: chase.seibert+opensubscriber at gmail.com
> Emmanuel,
> Regarding HSEARCH-251, and
> http://www.opensubscriber.com/message/hibernate-dev@lists.jboss.org/9770383.html
> Being able to query just a single shard or subset of shards would be
> awesome. I was thinking of a similar API:
> IndexShardingStrategy:
> public DirectoryProvider<?>[]
> getDirectoryProviderForShard(int shardNum);
> FullTextQuery:
> public void enableShardFilter(int shardNum);
> public void enableShardFilters(int[] shardNums);
> FullTextQuery.buildSearcher() would need to be modified to call
> getDirectoryProviderForShard() for each shardNum if shardNums are set,
> otherwise it should continue to use getDirectoryProvidersForAllShards();
> Calling this API from a consumer's stand-point would look like:
> FullTextQuery fullTextQuery =
> fullTextSession.createFullTextQuery(luceneQuery, entityClass);
> fullTextQuery.enableShardFilter(5);
> fullTextQuery.list();
> This could be changed to pass named shards easily. I could prototype this
> and submit a .patch if you are interested.
>  -Chase
> --
> This message was sent on behalf of chase.seibert+opensubscriber at gmail.com at
> openSubscriber.com
> http://www.opensubscriber.com/message/hibernate-dev@lists.jboss.org/9800518.html
> _______________________________________________
> 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