Search in sources :

Example 1 with SearchContextId

use of org.opensearch.action.search.SearchContextId in project OpenSearch by opensearch-project.

the class RestSearchAction method preparePointInTime.

static void preparePointInTime(SearchRequest request, RestRequest restRequest, NamedWriteableRegistry namedWriteableRegistry) {
    assert request.pointInTimeBuilder() != null;
    ActionRequestValidationException validationException = null;
    if (request.indices().length > 0) {
        validationException = addValidationError("[indices] cannot be used with point in time", validationException);
    }
    if (request.indicesOptions() != SearchRequest.DEFAULT_INDICES_OPTIONS) {
        validationException = addValidationError("[indicesOptions] cannot be used with point in time", validationException);
    }
    if (request.routing() != null) {
        validationException = addValidationError("[routing] cannot be used with point in time", validationException);
    }
    if (request.preference() != null) {
        validationException = addValidationError("[preference] cannot be used with point in time", validationException);
    }
    if (restRequest.paramAsBoolean("ccs_minimize_roundtrips", false)) {
        validationException = addValidationError("[ccs_minimize_roundtrips] cannot be used with point in time", validationException);
        request.setCcsMinimizeRoundtrips(false);
    }
    ExceptionsHelper.reThrowIfNotNull(validationException);
    final IndicesOptions indicesOptions = request.indicesOptions();
    final IndicesOptions stricterIndicesOptions = IndicesOptions.fromOptions(indicesOptions.ignoreUnavailable(), indicesOptions.allowNoIndices(), false, false, false, true, true, indicesOptions.ignoreThrottled());
    request.indicesOptions(stricterIndicesOptions);
    final SearchContextId searchContextId = SearchContextId.decode(namedWriteableRegistry, request.pointInTimeBuilder().getId());
    request.indices(searchContextId.getActualIndices());
}
Also used : ActionRequestValidationException(org.opensearch.action.ActionRequestValidationException) SearchContextId(org.opensearch.action.search.SearchContextId) IndicesOptions(org.opensearch.action.support.IndicesOptions)

Aggregations

ActionRequestValidationException (org.opensearch.action.ActionRequestValidationException)1 SearchContextId (org.opensearch.action.search.SearchContextId)1 IndicesOptions (org.opensearch.action.support.IndicesOptions)1