Search in sources :

Example 1 with ReducedSearchErrorContext

use of com.couchbase.client.core.error.context.ReducedSearchErrorContext in project couchbase-jvm-clients by couchbase.

the class ReactiveCluster method searchQuery.

/**
 * Performs a Full Text Search (FTS) query with custom {@link SearchOptions}.
 *
 * @param query the query, in the form of a {@link SearchQuery}
 * @param options the custom options for this query.
 * @return the {@link SearchRequest} once the response arrives successfully, inside a {@link Mono}
 */
public Mono<ReactiveSearchResult> searchQuery(final String indexName, final SearchQuery query, final SearchOptions options) {
    notNull(query, "SearchQuery", () -> new ReducedSearchErrorContext(indexName, null));
    notNull(options, "SearchOptions", () -> new ReducedSearchErrorContext(indexName, query.export().toMap()));
    SearchOptions.Built opts = options.build();
    JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
    return Mono.defer(() -> {
        return SearchAccessor.searchQueryReactive(asyncCluster.core(), asyncCluster.searchRequest(indexName, query, opts), serializer);
    });
}
Also used : ReducedSearchErrorContext(com.couchbase.client.core.error.context.ReducedSearchErrorContext) SearchOptions(com.couchbase.client.java.search.SearchOptions) JsonSerializer(com.couchbase.client.java.codec.JsonSerializer)

Example 2 with ReducedSearchErrorContext

use of com.couchbase.client.core.error.context.ReducedSearchErrorContext in project couchbase-jvm-clients by couchbase.

the class AsyncCluster method searchQuery.

/**
 * Performs a Full Text Search (FTS) query with custom {@link SearchOptions}.
 *
 * @param query the query, in the form of a {@link SearchQuery}
 * @param options the custom options for this query.
 * @return the {@link SearchRequest} once the response arrives successfully, inside a {@link CompletableFuture}
 */
public CompletableFuture<SearchResult> searchQuery(final String indexName, final SearchQuery query, final SearchOptions options) {
    notNull(query, "SearchQuery", () -> new ReducedSearchErrorContext(indexName, null));
    notNull(options, "SearchOptions", () -> new ReducedSearchErrorContext(indexName, query.export().toMap()));
    SearchOptions.Built opts = options.build();
    JsonSerializer serializer = opts.serializer() == null ? environment.get().jsonSerializer() : opts.serializer();
    return SearchAccessor.searchQueryAsync(core, searchRequest(indexName, query, opts), serializer);
}
Also used : ReducedSearchErrorContext(com.couchbase.client.core.error.context.ReducedSearchErrorContext) SearchOptions(com.couchbase.client.java.search.SearchOptions) JsonSerializer(com.couchbase.client.java.codec.JsonSerializer)

Example 3 with ReducedSearchErrorContext

use of com.couchbase.client.core.error.context.ReducedSearchErrorContext in project couchbase-jvm-clients by couchbase.

the class AsyncCluster method searchRequest.

SearchRequest searchRequest(final String indexName, final SearchQuery query, final SearchOptions.Built opts) {
    notNullOrEmpty(indexName, "IndexName", () -> new ReducedSearchErrorContext(indexName, query.export().toMap()));
    Duration timeout = opts.timeout().orElse(environment.get().timeoutConfig().searchTimeout());
    JsonObject params = query.export();
    opts.injectParams(indexName, params, timeout);
    byte[] bytes = params.toString().getBytes(StandardCharsets.UTF_8);
    RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.get().retryStrategy());
    final RequestSpan span = environment().requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_SEARCH, opts.parentSpan().orElse(null));
    SearchRequest request = new SearchRequest(timeout, core.context(), retryStrategy, authenticator, indexName, bytes, span);
    request.context().clientContext(opts.clientContext());
    return request;
}
Also used : ReducedSearchErrorContext(com.couchbase.client.core.error.context.ReducedSearchErrorContext) SearchRequest(com.couchbase.client.core.msg.search.SearchRequest) JsonObject(com.couchbase.client.java.json.JsonObject) Duration(java.time.Duration) RetryStrategy(com.couchbase.client.core.retry.RetryStrategy) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Aggregations

ReducedSearchErrorContext (com.couchbase.client.core.error.context.ReducedSearchErrorContext)3 JsonSerializer (com.couchbase.client.java.codec.JsonSerializer)2 SearchOptions (com.couchbase.client.java.search.SearchOptions)2 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)1 SearchRequest (com.couchbase.client.core.msg.search.SearchRequest)1 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)1 JsonObject (com.couchbase.client.java.json.JsonObject)1 Duration (java.time.Duration)1