Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public Task EnsureIndexesCreatedAsync(CancellationToken cancellationToken)
Builders<BranchMongoEntity>
.IndexKeys
.Text(x => x.Name);
var indexOptions = new CreateIndexOptions { Name = "text_index" };
var indexOptions = new CreateIndexOptions
{
Name = "text_index",
Collation = MongoRepositoryHelper.CreateDefaultCollation(),
};
var indexModel = new CreateIndexModel<BranchMongoEntity>(indexKeysDefinition, indexOptions);
return Collection.Indexes.CreateOneAsync(indexModel, cancellationToken: cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public Task EnsureIndexesCreatedAsync(CancellationToken cancellationToken)
.Text(x => x.FirstName)
.Text(x => x.LastName)
.Text(x => x.FullName);
var indexOptions = new CreateIndexOptions { Name = "text_index" };
var indexOptions = new CreateIndexOptions
{
Name = "text_index",
Collation = MongoRepositoryHelper.CreateDefaultCollation(),
};
var indexModel = new CreateIndexModel<EmployeeMongoEntity>(indexKeysDefinition, indexOptions);
return Collection.Indexes.CreateOneAsync(indexModel, cancellationToken: cancellationToken);
}
Expand Down
14 changes: 14 additions & 0 deletions src/API.Persistence/Mongo/Repositories/MongoRepositoryHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MongoDB.Driver;

namespace Fossa.API.Persistence.Mongo.Repositories;

public static class MongoRepositoryHelper
{
public static Collation CreateDefaultCollation()
{
return new Collation(
"simple",
strength: CollationStrength.Primary,
alternate: CollationAlternate.Shifted);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ namespace Fossa.API.Persistence.Mongo.Repositories
{
public MongoDatabaseProvider(TIKSN.Data.Mongo.IMongoClientProvider mongoClientProvider, Microsoft.Extensions.Configuration.IConfiguration configuration) { }
}
public static class MongoRepositoryHelper
{
public static MongoDB.Driver.Collation CreateDefaultCollation() { }
}
public class SystemPropertiesMongoRepository : TIKSN.Data.Mongo.MongoRepository<Fossa.API.Persistence.Mongo.Entities.SystemPropertiesMongoEntity, long>, Fossa.API.Persistence.Mongo.Repositories.ISystemPropertiesMongoRepository, TIKSN.Data.IQueryRepository<Fossa.API.Persistence.Mongo.Entities.SystemPropertiesMongoEntity, long>, TIKSN.Data.IRepository<Fossa.API.Persistence.Mongo.Entities.SystemPropertiesMongoEntity>, TIKSN.Data.IStreamRepository<Fossa.API.Persistence.Mongo.Entities.SystemPropertiesMongoEntity>, TIKSN.Data.Mongo.IMongoRepository<Fossa.API.Persistence.Mongo.Entities.SystemPropertiesMongoEntity, long>
{
public SystemPropertiesMongoRepository(TIKSN.Data.Mongo.IMongoClientSessionProvider mongoClientSessionProvider, TIKSN.Data.Mongo.IMongoDatabaseProvider mongoDatabaseProvider) { }
Expand Down