use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveScope method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions} on a scope
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link ReactiveAnalyticsResult} once the response arrives successfully.
*/
public Mono<ReactiveAnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return AnalyticsAccessor.analyticsQueryReactive(asyncScope.core(), asyncScope.analyticsRequest(statement, opts), serializer);
});
}
use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveCluster method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions}.
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link ReactiveAnalyticsResult} once the response arrives successfully.
*/
public Mono<ReactiveAnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return AnalyticsAccessor.analyticsQueryReactive(asyncCluster.core(), asyncCluster.analyticsRequest(statement, opts), serializer);
});
}
use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.
the class AsyncAnalyticsIndexManager method toAnalyticsOptions.
/**
* Converts the common options into a single {@link AnalyticsOptions} so it can be passed down to the query.
*
* @param options the options to convert.
* @return the converted {@link AnalyticsOptions}.
*/
private static AnalyticsOptions toAnalyticsOptions(final CommonOptions<?>.BuiltCommonOptions options) {
AnalyticsOptions result = analyticsOptions();
options.timeout().ifPresent(result::timeout);
options.retryStrategy().ifPresent(result::retryStrategy);
result.clientContext(options.clientContext());
return result;
}
use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method findByAnalytics.
@Test
// needs analytics data set
@Disabled
public void findByAnalytics() {
// 2
AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("413"));
try {
List<Airport> found = couchbaseTemplate.findByAnalytics(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(options).all();
assertEquals(saved, found);
} finally {
couchbaseTemplate.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId());
}
}
use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method findByAnalyticsOptions.
@Test
// needs analytics data set
@Disabled
public void findByAnalyticsOptions() {
// 2
AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofNanos(10));
assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.findByAnalytics(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).all());
}
Aggregations