diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index ec350f1b..193eaee0 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -454,12 +454,19 @@ namespace AyaNova.Biz //BREAK OBJECT TEXT STRINGS INTO KEYWORD LIST List KeyWordList = Break(p.LocaleId, p.Words); - + //BREAK NAME STRING List NameKeyWordList = Break(p.LocaleId, p.Name); + //BUILD ALL KEYWORDS LIST + List tempList = new List(); + tempList.AddRange(KeyWordList); + tempList.AddRange(p.Tags); + var DistinctAllKeywordsCombinedList=tempList.Distinct(); + // AllKeyWordsCombinedList=((IEnumerable)AllKeyWordsCombinedList).Distinct(); + //EARLY EXIT IF NO KEYWORDS OR NAME RECORD OR TAGS TO PROCESS - if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(p.Name) && p.Tags.Count==0) + if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(p.Name)) { return; } @@ -469,7 +476,8 @@ namespace AyaNova.Biz List MatchingKeywordIdList = new List(); //ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS - var ExistingKeywordMatches = ServiceProviderProvider.DBContext.SearchDictionary.AsNoTracking().Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word); + // var ExistingKeywordMatches = ServiceProviderProvider.DBContext.SearchDictionary.AsNoTracking().Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word); + var ExistingKeywordMatches = ServiceProviderProvider.DBContext.SearchDictionary.AsNoTracking().Where(m => DistinctAllKeywordsCombinedList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word); //Put the matching keyword ID's into the list foreach (KeyValuePair K in ExistingKeywordMatches) { @@ -477,6 +485,9 @@ namespace AyaNova.Biz if (NameKeyWordList.Contains(K.Value)) IsName = true; MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName }); +//todo: make two records if both in + + } //-------- START CRITICAL SECTION ----------- @@ -486,7 +497,7 @@ namespace AyaNova.Biz var log = AyaNova.Util.ApplicationLogging.CreateLogger("### Search::ProcessKeywords ###"); #endif - foreach (string KeyWord in KeyWordList) + foreach (string KeyWord in DistinctAllKeywordsCombinedList) { if (!ExistingKeywordMatches.ContainsValue(KeyWord)) { @@ -557,7 +568,7 @@ namespace AyaNova.Biz var NewSearchKeyList = new List(); foreach (MatchingDictionaryEntry E in MatchingKeywordIdList) { - NewSearchKeyList.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, InTags=E.InTags, ObjectId = p.ObjectId, ObjectType = p.ObjectType }); + NewSearchKeyList.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, InTags = E.InTags, ObjectId = p.ObjectId, ObjectType = p.ObjectType }); } var CtSearchKeyAdd = ServiceProviderProvider.DBContext; CtSearchKeyAdd.SearchKey.AddRange(NewSearchKeyList); @@ -576,7 +587,7 @@ namespace AyaNova.Biz public MatchingDictionaryEntry() { InName = false; - InTags=false; + InTags = false; DictionaryId = -1; } }