private SearchResponse getSearchResponse ( KunderaQuery kunderaQuery , FilteredQueryBuilder queryBuilder , QueryBuilder filter , ESQuery query , EntityMetadata m , int firstResult , int maxResults , KunderaMetadata kunderaMetadata ) { SearchRequestBuilder builder = client . prepareSearch ( m . getSchema ( ) . toLowerCase ( ) ) . setTypes ( m . getEntityClazz ( ) . getSimpleName ( ) ) ; AggregationBuilder aggregation = query . buildAggregation ( kunderaQuery , m , filter ) ; if ( aggregation == null ) { builder . setQuery ( queryBuilder ) ; builder . setFrom ( firstResult ) ; builder . setSize ( maxResults ) ; addSortOrder ( builder , kunderaQuery , m , kunderaMetadata ) ; } else { log . debug ( "Aggregated query identified" ) ; builder . addAggregation ( aggregation ) ; if ( kunderaQuery . getResult ( ) . length == 1 || ( kunderaQuery . isSelectStatement ( ) && KunderaQueryUtils . hasGroupBy ( kunderaQuery . getJpqlExpression ( ) ) ) ) { builder . setSize ( 0 ) ; } } SearchResponse response = null ; log . debug ( "Query generated: " + builder ) ; try { response = builder . execute ( ) . actionGet ( ) ; log . debug ( "Query execution response: " + response ) ; } catch ( ElasticsearchException e ) { log . error ( "Exception occured while executing query on Elasticsearch." , e ) ; throw new KunderaException ( "Exception occured while executing query on Elasticsearch." , e ) ; } return response ; }
Gets the search response .