From fb21ac930dd09c6cf767614ba7f4f3d8174cd621 Mon Sep 17 00:00:00 2001 From: Jannik Fried Date: Tue, 1 Aug 2023 12:03:05 +0200 Subject: [PATCH] Adapts MongoDB Indexing to support Cosomos DB Signed-off-by: Jannik Fried --- .../components/internal/mongodb/MongoDBBaSyxStorageAPI.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basyx.components/basyx.components.lib/src/main/java/org/eclipse/basyx/components/internal/mongodb/MongoDBBaSyxStorageAPI.java b/basyx.components/basyx.components.lib/src/main/java/org/eclipse/basyx/components/internal/mongodb/MongoDBBaSyxStorageAPI.java index 393faf7c..53599743 100644 --- a/basyx.components/basyx.components.lib/src/main/java/org/eclipse/basyx/components/internal/mongodb/MongoDBBaSyxStorageAPI.java +++ b/basyx.components/basyx.components.lib/src/main/java/org/eclipse/basyx/components/internal/mongodb/MongoDBBaSyxStorageAPI.java @@ -28,7 +28,6 @@ import static org.springframework.data.mongodb.core.query.Criteria.where; import static org.springframework.data.mongodb.core.query.Query.query; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -44,10 +43,11 @@ import org.eclipse.basyx.submodel.metamodel.map.qualifier.Identifiable; import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.File; import org.eclipse.basyx.vab.exception.provider.ResourceNotFoundException; +import org.springframework.data.domain.Sort.Direction; import org.springframework.data.mongodb.core.FindAndReplaceOptions; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.index.TextIndexDefinition; +import org.springframework.data.mongodb.core.index.Index; import org.springframework.data.mongodb.core.query.Query; import com.mongodb.client.MongoClient; @@ -87,7 +87,7 @@ public MongoDBBaSyxStorageAPI(String collectionName, Class type, BaSyxMongoDB } private void configureIndexKey() { - TextIndexDefinition idIndex = TextIndexDefinition.builder().onField(INDEX_KEY).build(); + Index idIndex = new Index().on(INDEX_KEY, Direction.ASC); this.mongoOps.indexOps(TYPE).ensureIndex(idIndex); }