Skip to content

Commit

Permalink
Adapts MongoDB Indexing to support Cosomos DB
Browse files Browse the repository at this point in the history
Signed-off-by: Jannik Fried <[email protected]>
  • Loading branch information
FriedJannik committed Aug 10, 2023
1 parent 54fdade commit 9034a3a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -87,7 +87,7 @@ public MongoDBBaSyxStorageAPI(String collectionName, Class<T> 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);
}

Expand Down

0 comments on commit 9034a3a

Please sign in to comment.