private <T> SearchResult<T> searchObjects(
            String indexName,
            QueryBuilder queryBuilder,
            int start,
            int size,
            List<String> sortOptions,
            String docType,
            boolean idOnly,
            Class<T> clazz)
            throws IOException {
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(queryBuilder);
        searchSourceBuilder.from(start);
        searchSourceBuilder.size(size);
        if (idOnly) {
            searchSourceBuilder.fetchSource(false);
        }

        if (sortOptions != null && !sortOptions.isEmpty()) {

            for (String sortOption : sortOptions) {
                SortOrder order = SortOrder.ASC;
                String field = sortOption;
                int index = sortOption.indexOf(":");
                if (index > 0) {
                    field = sortOption.substring(0, index);
                    order = SortOrder.valueOf(sortOption.substring(index + 1));
                }
                searchSourceBuilder.sort(new FieldSortBuilder(field).order(order));
            }
        }

        // Generate the actual request to send to ES.
        docType = StringUtils.isBlank(docTypeOverride) ? docType : docTypeOverride;
        SearchRequest searchRequest = new SearchRequest(indexName);
        searchRequest.types(docType);
        searchRequest.source(searchSourceBuilder);

        SearchResponse response = elasticSearchClient.search(searchRequest);
        return mapSearchResult(response, idOnly, clazz);
    }
Tries to find objects for a given query in an index.

@param indexName The name of the index.
@param queryBuilder The query to use for searching.
@param start The start to use.
@param size The total return size.
@param sortOptions A list of string options to sort in the form VALUE:ORDER; where ORDER is
    optional and can be either ASC OR DESC.
@param docType The document type to searchObjectIdsViaExpression for.
@return The SearchResults which includes the count and objects that were found.
@throws IOException If we cannot communicate with ES.
es6-persistence/src/main/java/com/netflix/conductor/es6/dao/index/ElasticSearchRestDAOV6.java