Handle auto index on field path. (#1169)

Closes #1166.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
This commit is contained in:
Michael Reiche
2021-08-11 10:29:05 -07:00
committed by GitHub
parent 9e3bfe5b71
commit 7d5e33ad71
4 changed files with 25 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ import org.springframework.data.couchbase.core.mapping.Document;
@Document
@CompositeQueryIndex(fields = { "id", "name desc" })
@CompositeQueryIndex(fields = { "id.something", "name desc" })
public class Airline extends ComparableEntity {
@Id String id;

View File

@@ -62,6 +62,14 @@ public class CouchbaseRepositoryAutoQueryIndexIntegrationTests extends ClusterAw
assertTrue(foundIndex.get().condition().get().contains("_class"));
}
@Test
void createsCompositeIndexWithPath() {
Optional<QueryIndex> foundIndex = cluster.queryIndexes().getAllIndexes(bucketName()).stream()
.filter(i -> i.name().equals("idx_airline_id_something_name")).findFirst();
assertTrue(foundIndex.isPresent());
assertTrue(foundIndex.get().condition().get().contains("_class"));
}
@Configuration
@EnableCouchbaseRepositories("org.springframework.data.couchbase")
static class Config extends AbstractCouchbaseConfiguration {