Source:
private IndexSearcher() { JsonArray typeFilters = new JsonArray(); String queriedEntityIdFieldName = null; Iterable<Class<?>> queriedEntityTypes = getQueriedEntityTypes(); for ( Class<?> queriedEntityType : queriedEntityTypes ) { entityTypesByName.put( queriedEntityType.getName(), queriedEntityType ); EntityIndexBinding binding = extendedIntegrator.getIndexBinding( queriedEntityType ); IndexManager[] indexManagers = binding.getIndexManagers(); for ( IndexManager indexManager : indexManagers ) { if ( !( indexManager instanceof ElasticsearchIndexManager ) ) { throw LOG.cannotRunEsQueryTargetingEntityIndexedWithNonEsIndexManager( queriedEntityType, jsonQuery.toString() ); } queriedEntityIdFieldName = binding.getDocumentBuilder().getIdentifierName(); ElasticsearchIndexManager esIndexManager = (ElasticsearchIndexManager) indexManager; indexNames.add( esIndexManager.getActualIndexName() ); } typeFilters.add( getEntityTypeFilter( queriedEntityType ) ); } this.idFieldName = queriedEntityIdFieldName; JsonObject filteredQuery = getFilteredQuery( jsonQuery.get( "query" ), typeFilters ); JsonBuilder.Object completeQuery = JsonBuilder.object(); for ( Entry<String, JsonElement> entry : jsonQuery.entrySet() ) { completeQuery.add( entry.getKey(), entry.getValue() ); } completeQuery.add( "query", filteredQuery ); if ( !getFacetManager().getFacetRequests().isEmpty() ) { JsonBuilder.Object facets = JsonBuilder.object(); for ( Entry<String, FacetingRequest> facetRequestEntry : getFacetManager().getFacetRequests().entrySet() ) { ToElasticsearch.addFacetingRequest( facets, facetRequestEntry.getValue() ); } completeQuery.add( "aggregations", facets ); } sortByDistanceIndex = getSortByDistanceIndex(); addScriptFields( completeQuery ); completeQueryAsString = completeQuery.build().toString(); }

Target:
private IndexSearcher() { JsonArray typeFilters = new JsonArray(); String queriedEntityIdFieldName = null; Iterable<Class<?>> queriedEntityTypes = getQueriedEntityTypes(); for ( Class<?> queriedEntityType : queriedEntityTypes ) { entityTypesByName.put( queriedEntityType.getName(), queriedEntityType ); EntityIndexBinding binding = extendedIntegrator.getIndexBinding( queriedEntityType ); IndexManager[] indexManagers = binding.getIndexManagers(); for ( IndexManager indexManager : indexManagers ) { if ( !( indexManager instanceof ElasticsearchIndexManager ) ) { throw LOG.cannotRunEsQueryTargetingEntityIndexedWithNonEsIndexManager( queriedEntityType, jsonQuery.toString() ); } queriedEntityIdFieldName = binding.getDocumentBuilder().getIdentifierName(); ElasticsearchIndexManager esIndexManager = (ElasticsearchIndexManager) indexManager; indexNames.add( esIndexManager.getActualIndexName() ); } typeFilters.add( getEntityTypeFilter( queriedEntityType ) ); } this.idFieldName = queriedEntityIdFieldName; JsonObject filteredQuery = getFilteredQuery( jsonQuery.get( "query" ), typeFilters ); JsonBuilder.Object completeQuery = JsonBuilder.object(); completeQuery.add( "query", filteredQuery ); if ( !getFacetManager().getFacetRequests().isEmpty() ) { JsonBuilder.Object facets = JsonBuilder.object(); for ( Entry<String, FacetingRequest> facetRequestEntry : getFacetManager().getFacetRequests().entrySet() ) { ToElasticsearch.addFacetingRequest( facets, facetRequestEntry.getValue() ); } completeQuery.add( "aggregations", facets ); } sortByDistanceIndex = getSortByDistanceIndex(); addScriptFields( completeQuery ); completeQueryAsString = completeQuery.build().toString(); }