This commit is contained in:
@@ -458,8 +458,15 @@ namespace AyaNova.Biz
|
|||||||
//BREAK NAME STRING
|
//BREAK NAME STRING
|
||||||
List<string> NameKeyWordList = Break(p.LocaleId, p.Name);
|
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
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
@@ -469,7 +476,8 @@ namespace AyaNova.Biz
|
|||||||
List<MatchingDictionaryEntry> MatchingKeywordIdList = new List<MatchingDictionaryEntry>();
|
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
|
//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
|
//Put the matching keyword ID's into the list
|
||||||
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
|
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
|
||||||
{
|
{
|
||||||
@@ -477,6 +485,9 @@ namespace AyaNova.Biz
|
|||||||
if (NameKeyWordList.Contains(K.Value))
|
if (NameKeyWordList.Contains(K.Value))
|
||||||
IsName = true;
|
IsName = true;
|
||||||
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName });
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName });
|
||||||
|
//todo: make two records if both in
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------- START CRITICAL SECTION -----------
|
//-------- START CRITICAL SECTION -----------
|
||||||
@@ -486,7 +497,7 @@ namespace AyaNova.Biz
|
|||||||
var log = AyaNova.Util.ApplicationLogging.CreateLogger("### Search::ProcessKeywords ###");
|
var log = AyaNova.Util.ApplicationLogging.CreateLogger("### Search::ProcessKeywords ###");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (string KeyWord in KeyWordList)
|
foreach (string KeyWord in DistinctAllKeywordsCombinedList)
|
||||||
{
|
{
|
||||||
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
||||||
{
|
{
|
||||||
@@ -557,7 +568,7 @@ namespace AyaNova.Biz
|
|||||||
var NewSearchKeyList = new List<SearchKey>();
|
var NewSearchKeyList = new List<SearchKey>();
|
||||||
foreach (MatchingDictionaryEntry E in MatchingKeywordIdList)
|
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;
|
var CtSearchKeyAdd = ServiceProviderProvider.DBContext;
|
||||||
CtSearchKeyAdd.SearchKey.AddRange(NewSearchKeyList);
|
CtSearchKeyAdd.SearchKey.AddRange(NewSearchKeyList);
|
||||||
@@ -576,7 +587,7 @@ namespace AyaNova.Biz
|
|||||||
public MatchingDictionaryEntry()
|
public MatchingDictionaryEntry()
|
||||||
{
|
{
|
||||||
InName = false;
|
InName = false;
|
||||||
InTags=false;
|
InTags = false;
|
||||||
DictionaryId = -1;
|
DictionaryId = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user