spring-projects / spring-projects/spring-data-couchbase
implement AnalyticsQuery
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 284
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
package org.springframework.data.couchbase.core.query;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.couchbase.core.CouchbaseTemplate;
import org.springframework.data.couchbase.domain.Airport;
import org.springframework.data.couchbase.domain.Config;
import org.springframework.data.couchbase.util.Capabilities;
import org.springframework.data.couchbase.util.ClusterType;
import org.springframework.data.couchbase.util.IgnoreWhen;
import org.springframework.data.couchbase.util.JavaIntegrationTests;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import com.couchbase.client.java.query.QueryOptions;
import com.couchbase.client.java.query.QueryScanConsistency;
import java.util.List;
@IgnoreWhen(missesCapabilities = Capabilities.QUERY, clusterTypes = ClusterType.MOCKED)
@SpringJUnitConfig(Config.class)
public class queryExample extends JavaIntegrationTests {
@Autowired CouchbaseTemplate template;
@Test
public void queryTest() {
N1QLExpression expression = N1QLExpression.x("SQL++ Query");
N1QLQuery query = buildQuery(expression, QueryScanConsistency.REQUEST_PLUS);
List<Airport> airports = template.findByQuery(Airport.class).matching(query).all();
System.err.println("airports: "+airports);
}
public static N1QLQuery buildQuery(N1QLExpression expression, QueryScanConsistency scanConsistency) {
QueryOptions opts = QueryOptions.queryOptions().scanConsistency(scanConsistency);
return new N1QLQuery(expression, opts);
}
@Test
public void analyticsTest() {
N1QLExpression expression = N1QLExpression.x("SQL++ Query");
AnalyticsQuery query = buildAnalytics(expression, QueryScanConsistency.REQUEST_PLUS);
List<Airport> airports = template.findByQuery(Airport.class).matching(query).all();
System.err.println("airports: "+airports);
}
private AnalyticsQuery buildAnalytics(N1QLExpression expression, QueryScanConsistency scanConsistency) {
QueryOptions opts = QueryOptions.queryOptions().scanConsistency(scanConsistency);
return new AnalyticsQuery(expression, opts);
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides an example using N1QLQuery and the requested AnalyticsQuery through CouchbaseTemplate.findByQuery(...).matching(...).all(). Compare the existing N1QLQuery path with the AnalyticsQuery usage, then verify completion by making analyticsTest compile and execute with the supplied QueryOptions and scan consistency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100