From 8db1ba3114a8dc0a82cacba563bf0b47bac8f011 Mon Sep 17 00:00:00 2001 From: fuencui <90531683+fuencui@users.noreply.github.com> Date: Fri, 13 Jan 2023 11:53:36 -0800 Subject: [PATCH] Fix case-sensitive of Find a domain (#1814) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- Backend/Repositories/SemanticDomainRepository.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Backend/Repositories/SemanticDomainRepository.cs b/Backend/Repositories/SemanticDomainRepository.cs index a356d8dd97..e4ef9f197e 100644 --- a/Backend/Repositories/SemanticDomainRepository.cs +++ b/Backend/Repositories/SemanticDomainRepository.cs @@ -3,6 +3,7 @@ using BackendFramework.Interfaces; using BackendFramework.Models; using MongoDB.Driver; +using MongoDB.Bson; namespace BackendFramework.Repositories { @@ -36,7 +37,7 @@ public SemanticDomainRepository(ISemanticDomainContext context) { var filterDef = new FilterDefinitionBuilder(); 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