It is supposedly possible to filter by shard in queries by using a specific {{ShardIdentifierProvider}} that would implement {{org.hibernate.search.store.ShardIdentifierProvider.getShardIdentifiersForQuery(FullTextFilterImplementor[])}} in such a way that some filters would be interpreted as shard filters. See {{org.hibernate.search.test.sharding.LogRotationExampleTest.filtersTest()}}, and more specifically {{org.hibernate.search.test.sharding.LogRotationExampleTest.LogMessageShardingStrategy.getShardIdentifiersForQuery(FullTextFilterImplementor[])}} for an example.
When using Elasticsearch, though, such filtering doesn't work. {{org.hibernate.search.test.sharding.LogRotationExampleTest.filtersTest()}}, in particular, fails.
The main issue is that {{org.hibernate.search.store.ShardIdentifierProvider.getShardIdentifiersForQuery(FullTextFilterImplementor[])}} seems to be ignored in {{org.hibernate.search.elasticsearch.impl.ElasticsearchHSQueryImpl}}. {{LuceneHSQuery}} takes it into account in {{org.hibernate.search.query.engine.impl.LuceneHSQuery.getIndexManagers(EntityIndexBinding)}} when it calls {{org.hibernate.search.store.IndexShardingStrategy.getIndexManagersForQuery(FullTextFilterImplementor[])}}.
Note: some tests have been disabled because of this bug. Please search for this ticket's code ({{HSEARCH-2477}}) in the source and re-enabled the tests when the issue has been fixed. |
|