Skip to content

Commit da8b059

Browse files
committed
MMI-3342 Fix highlight search terms (bcgov#2488)
1 parent 2cf605e commit da8b059

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

libs/net/elastic/Extensions/RegexSettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@ public static partial class RegexSettings
2929

3030
[GeneratedRegex(@"(\sAND\s|\sOR\s|\sNOT\s|\s?\&\&\s?|\s?\|\|\s?|\s?[\+\-\!]\s?)", RegexOptions.IgnoreCase)]
3131
public static partial Regex RemoveAdvancedKeywordsRegex();
32+
33+
[GeneratedRegex(@"\b\w+:/(\\/|[^/])*/")]
34+
public static partial Regex RemoveFieldedSearchRegex();
3235
#endregion
3336
}

libs/net/elastic/Extensions/StringExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class StringExtensions
1616
static readonly Regex EndOfQuote = RegexSettings.EndOfQuoteRegex();
1717
static readonly Regex RemoveSimpleKeywords = RegexSettings.RemoveSimpleKeywordsRegex();
1818
static readonly Regex RemoveAdvancedKeywords = RegexSettings.RemoveAdvancedKeywordsRegex();
19-
19+
static readonly Regex RemoveFieldedSearch = RegexSettings.RemoveFieldedSearchRegex();
2020
#endregion
2121

2222
#region Methods
@@ -32,12 +32,13 @@ public static IEnumerable<string> ExtractKeywords(this string search, string que
3232
var isAdvanced = queryType == "query-string";
3333
var keywords = new List<string>();
3434
var startOfPhrase = -1;
35-
var endOfPhrase = -1;
35+
int endOfPhrase;
3636
var phrase = new StringBuilder();
3737

3838
if (isAdvanced)
3939
{
40-
var cleanSearch = RemoveAdvancedKeywords.Replace(search, " ");
40+
var cleanSearch = RemoveFieldedSearch.Replace(search, " ");
41+
cleanSearch = RemoveAdvancedKeywords.Replace(cleanSearch, " ");
4142
var tokens = cleanSearch.Split(" ", StringSplitOptions.RemoveEmptyEntries);
4243

4344
// Iterate through each token to determine whether it is a keyword that should be marked.

0 commit comments

Comments
 (0)