- When indexing, using the routing key provided by the mapper.
- When querying, using the routing key provided by the user (note that we only need to target a superset of the documents with this routing key; if the users needs more, he'll need to use an additional predicate).
For Elasticsearch it might already be done (it’s quite easy, we just pass the key to ES), but there will be more work for Lucene.
Also, test sharding. See org.hibernate.search.v6poc.integrationtest.backend.tck.RoutingIT.
See also HSEARCH-3313 Open for dynamic sharding / "partitioning"