This commit is contained in:
2018-12-06 18:52:14 +00:00
parent 11c7dd096b
commit 14f4fd3db6

View File

@@ -454,12 +454,19 @@ namespace AyaNova.Biz
//BREAK OBJECT TEXT STRINGS INTO KEYWORD LIST
List<string> KeyWordList = Break(p.LocaleId, p.Words);
//BREAK NAME STRING
List<string> NameKeyWordList = Break(p.LocaleId, p.Name);
//BUILD ALL KEYWORDS LIST
List<string> tempList = new List<string>();
tempList.AddRange(KeyWordList);
tempList.AddRange(p.Tags);
var DistinctAllKeywordsCombinedList=tempList.Distinct();
// AllKeyWordsCombinedList=((IEnumerable<string>)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<MatchingDictionaryEntry> MatchingKeywordIdList = new List<MatchingDictionaryEntry>();
//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<long, string> 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<SearchKey>();
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;
}
}