private static void configureRouting ( IssueQuery query , SearchOptions options , SearchRequestBuilder requestBuilder ) { Collection < String > uuids = query . projectUuids ( ) ; if ( ! uuids . isEmpty ( ) && options . getFacets ( ) . isEmpty ( ) ) { requestBuilder . setRouting ( uuids . stream ( ) . map ( AuthorizationDoc :: idOf ) . toArray ( String [ ] :: new ) ) ; } }
Optimization - do not send ES request to all shards when scope is restricted to a set of projects . Because project UUID is used for routing the request can be sent to only the shards containing the specified projects . Note that sticky facets may involve all projects so this optimization must be disabled when facets are enabled .