public virtual async Task SearchAsync()

in Elastic.SemanticKernel.Connectors.Elasticsearch/MockableElasticsearchClient.cs [289:318]


    public virtual async Task<(long total, (string id, JsonObject document, double? score)[] hits)> SearchAsync(
        IndexName indexName,
        Query query,
        int? from,
        int? size,
        CancellationToken cancellationToken = default)
    {
        Verify.NotNull(indexName);
        Verify.NotNull(query);

        var response = await ElasticsearchClient
            .SearchAsync<JsonObject>(
                new SearchRequest(indexName)
                {
                    Query = query,
                    From = from,
                    Size = size,
                    RequestConfiguration = CustomUserAgentRequestConfiguration
                },
                cancellationToken
            )
            .ConfigureAwait(false);

        if (!response.IsSuccess())
        {
            throw new TransportException(PipelineFailure.Unexpected, "Failed to execute request.", response);
        }

        return (response.Total, [.. response.Hits.Select(hit => (hit.Id!, hit.Source!, hit.Score))]);
    }