Search in sources :

Example 1 with SearchMode

use of com.enonic.xp.node.SearchMode in project xp by enonic.

the class SearchExecutor method execute.

public SearchResult execute(final SearchRequest searchRequest) {
    final ElasticsearchQuery query = ESQueryTranslator.translate(searchRequest);
    final SearchMode searchMode = query.getSearchMode();
    final int size = query.getSize();
    final boolean anyAggregations = !query.getAggregations().isEmpty();
    if (searchMode.equals(SearchMode.COUNT)) {
        return CountExecutor.create(this.client).build().execute(query);
    }
    if (size == NodeSearchService.GET_ALL_SIZE_FLAG) {
        if (anyAggregations) {
            LOG.debug("Query with size [" + query.getSize() + "] > threshold [" + SCROLL_THRESHOLD + "] but with aggregations. Scan not possible.");
        } else {
            return ScrollExecutor.create(this.client).build().execute(query);
        }
    }
    return doSearch(query);
}
Also used : ElasticsearchQuery(com.enonic.xp.repo.impl.elasticsearch.query.ElasticsearchQuery) SearchMode(com.enonic.xp.node.SearchMode)

Aggregations

SearchMode (com.enonic.xp.node.SearchMode)1 ElasticsearchQuery (com.enonic.xp.repo.impl.elasticsearch.query.ElasticsearchQuery)1