Skip to content

Commit

Permalink
Fix case-sensitive of Find a domain (#1814)
Browse files Browse the repository at this point in the history
* Fix case-sensitive of Find a domain from backend

“Find a domain” search field at top of the domain tree should not be case-sensitive.
Filtering on string fields in Mongodb is case sensitive without using regular expressions.
In order to implement insensitive search use filterDef.Regex instead
  • Loading branch information
fuencui authored Jan 13, 2023
1 parent d199b80 commit 8db1ba3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Backend/Repositories/SemanticDomainRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BackendFramework.Interfaces;
using BackendFramework.Models;
using MongoDB.Driver;
using MongoDB.Bson;

namespace BackendFramework.Repositories
{
Expand Down Expand Up @@ -36,7 +37,7 @@ public SemanticDomainRepository(ISemanticDomainContext context)
{
var filterDef = new FilterDefinitionBuilder<SemanticDomainTreeNode>();
var filter = filterDef.And(
filterDef.Eq(x => x.Name, name),
filterDef.Regex(x => x.Name, new BsonRegularExpression("/^" + name + "$/i")),
filterDef.Eq(x => x.Lang, lang));
var domain = await _context.SemanticDomains.FindAsync(filter: filter);
try
Expand Down

0 comments on commit 8db1ba3

Please sign in to comment.