Search in sources :

Example 1 with InternalScrollSearchRequest

use of org.elasticsearch.search.internal.InternalScrollSearchRequest in project elasticsearch by elastic.

the class SearchScrollRequestTests method testInternalScrollSearchRequestSerialization.

public void testInternalScrollSearchRequestSerialization() throws IOException {
    SearchScrollRequest searchScrollRequest = createSearchScrollRequest();
    InternalScrollSearchRequest internalScrollSearchRequest = new InternalScrollSearchRequest(searchScrollRequest, randomLong());
    try (BytesStreamOutput output = new BytesStreamOutput()) {
        internalScrollSearchRequest.writeTo(output);
        try (StreamInput in = output.bytes().streamInput()) {
            InternalScrollSearchRequest deserializedRequest = new InternalScrollSearchRequest();
            deserializedRequest.readFrom(in);
            assertEquals(deserializedRequest.id(), internalScrollSearchRequest.id());
            assertEquals(deserializedRequest.scroll(), internalScrollSearchRequest.scroll());
            assertNotSame(deserializedRequest, internalScrollSearchRequest);
        }
    }
}
Also used : InternalScrollSearchRequest(org.elasticsearch.search.internal.InternalScrollSearchRequest) StreamInput(org.elasticsearch.common.io.stream.StreamInput) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput)

Example 2 with InternalScrollSearchRequest

use of org.elasticsearch.search.internal.InternalScrollSearchRequest in project elasticsearch by elastic.

the class SearchScrollQueryAndFetchAsyncAction method executePhase.

void executePhase(final int shardIndex, DiscoveryNode node, final long searchId) {
    InternalScrollSearchRequest internalRequest = internalScrollSearchRequest(searchId, request);
    searchTransportService.sendExecuteFetch(node, internalRequest, task, new ActionListener<ScrollQueryFetchSearchResult>() {

        @Override
        public void onResponse(ScrollQueryFetchSearchResult result) {
            queryFetchResults.set(shardIndex, result.result());
            if (counter.decrementAndGet() == 0) {
                finishHim();
            }
        }

        @Override
        public void onFailure(Exception t) {
            onPhaseFailure(t, searchId, shardIndex);
        }
    });
}
Also used : InternalScrollSearchRequest(org.elasticsearch.search.internal.InternalScrollSearchRequest) ScrollQueryFetchSearchResult(org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult)

Example 3 with InternalScrollSearchRequest

use of org.elasticsearch.search.internal.InternalScrollSearchRequest in project elasticsearch by elastic.

the class SearchScrollQueryThenFetchAsyncAction method executeQueryPhase.

private void executeQueryPhase(final int shardIndex, final AtomicInteger counter, DiscoveryNode node, final long searchId) {
    InternalScrollSearchRequest internalRequest = internalScrollSearchRequest(searchId, request);
    searchTransportService.sendExecuteQuery(node, internalRequest, task, new ActionListener<ScrollQuerySearchResult>() {

        @Override
        public void onResponse(ScrollQuerySearchResult result) {
            queryResults.set(shardIndex, result.queryResult());
            if (counter.decrementAndGet() == 0) {
                try {
                    executeFetchPhase();
                } catch (Exception e) {
                    onFailure(e);
                }
            }
        }

        @Override
        public void onFailure(Exception t) {
            onQueryPhaseFailure(shardIndex, counter, searchId, t);
        }
    });
}
Also used : InternalScrollSearchRequest(org.elasticsearch.search.internal.InternalScrollSearchRequest) ScrollQuerySearchResult(org.elasticsearch.search.query.ScrollQuerySearchResult)

Aggregations

InternalScrollSearchRequest (org.elasticsearch.search.internal.InternalScrollSearchRequest)3 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 ScrollQueryFetchSearchResult (org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult)1 ScrollQuerySearchResult (org.elasticsearch.search.query.ScrollQuerySearchResult)1