Search in sources :

Example 6 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.

the class CouchbaseTemplateQueryCollectionIntegrationTests method findByAnalyticsOther.

@Test
// needs analytics data set
@Disabled
public void findByAnalyticsOther() {
    // 2
    AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofSeconds(10));
    Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("566"));
    try {
        List<Airport> found = couchbaseTemplate.findByAnalytics(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).all();
        assertEquals(saved, found);
    } finally {
        couchbaseTemplate.removeById().inScope(otherScope).inCollection(otherCollection).one(saved.getId());
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 7 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method findByAnalyticsOther.

@Test
// needs analytics data set
@Disabled
public void findByAnalyticsOther() {
    // 2
    AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("lowh")).block();
    try {
        List<Airport> found = template.findByAnalytics(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).all().collectList().block();
        assertEquals(saved, found);
    } finally {
        template.removeById().inScope(otherScope).inCollection(otherCollection).one(saved.getId()).block();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 8 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method findByAnalyticsOptions.

@Test
// needs analytics data set
@Disabled
public void findByAnalyticsOptions() {
    // 2
    AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofNanos(10));
    assertThrows(AmbiguousTimeoutException.class, () -> template.findByAnalytics(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).all().collectList().block());
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 9 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method findByAnalytics.

@Test
// needs analytics data set
@Disabled
public void findByAnalytics() {
    // 2
    AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("low8")).block();
    try {
        List<Airport> found = template.findByAnalytics(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(options).all().collectList().block();
        assertEquals(saved, found);
    } finally {
        template.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId()).block();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 10 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.

the class AsyncScope 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 AnalyticsResult} once the response arrives successfully.
 */
public CompletableFuture<AnalyticsResult> 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 AnalyticsAccessor.analyticsQueryAsync(core, analyticsRequest(statement, opts), serializer);
}
Also used : ReducedAnalyticsErrorContext(com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext) JsonSerializer(com.couchbase.client.java.codec.JsonSerializer) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions)

Aggregations

AnalyticsOptions (com.couchbase.client.java.analytics.AnalyticsOptions)12 Disabled (org.junit.jupiter.api.Disabled)6 Test (org.junit.jupiter.api.Test)6 Airport (org.springframework.data.couchbase.domain.Airport)6 ReducedAnalyticsErrorContext (com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext)4 JsonSerializer (com.couchbase.client.java.codec.JsonSerializer)4 ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions)2 CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions)2 CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions)2 CreateIndexAnalyticsOptions.createIndexAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateIndexAnalyticsOptions.createIndexAnalyticsOptions)2 CreateLinkAnalyticsOptions.createLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateLinkAnalyticsOptions.createLinkAnalyticsOptions)2 DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions)2 DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions)2 DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions)2 DropIndexAnalyticsOptions.dropIndexAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropIndexAnalyticsOptions.dropIndexAnalyticsOptions)2 DropLinkAnalyticsOptions.dropLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropLinkAnalyticsOptions.dropLinkAnalyticsOptions)2 GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions)2 GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions)2 GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions)2 GetLinksAnalyticsOptions.getLinksAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetLinksAnalyticsOptions.getLinksAnalyticsOptions)2