This commit is contained in:
@@ -462,8 +462,8 @@ namespace AyaNova.Biz
|
|||||||
List<string> tempList = new List<string>();
|
List<string> tempList = new List<string>();
|
||||||
tempList.AddRange(KeyWordList);
|
tempList.AddRange(KeyWordList);
|
||||||
tempList.AddRange(p.Tags);
|
tempList.AddRange(p.Tags);
|
||||||
var DistinctAllKeywordsCombinedList=tempList.Distinct();
|
var DistinctAllKeywordsCombinedList = tempList.Distinct();
|
||||||
// AllKeyWordsCombinedList=((IEnumerable<string>)AllKeyWordsCombinedList).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))
|
if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(p.Name))
|
||||||
@@ -476,17 +476,19 @@ 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);
|
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)
|
||||||
{
|
{
|
||||||
bool IsName = false;
|
//Name or regular word match?
|
||||||
if (NameKeyWordList.Contains(K.Value))
|
bool IsName = NameKeyWordList.Contains(K.Value);
|
||||||
IsName = true;
|
if (IsName || KeyWordList.Contains(K.Value))
|
||||||
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
|
|
||||||
|
|
||||||
|
//Tag match?
|
||||||
|
if (p.Tags.Contains(K.Value))
|
||||||
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InTags = true });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +515,24 @@ namespace AyaNova.Biz
|
|||||||
var CtAdd = ServiceProviderProvider.DBContext;
|
var CtAdd = ServiceProviderProvider.DBContext;
|
||||||
CtAdd.SearchDictionary.Add(NewWord);
|
CtAdd.SearchDictionary.Add(NewWord);
|
||||||
CtAdd.SaveChanges();
|
CtAdd.SaveChanges();
|
||||||
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = NewWord.Id, InName = NameKeyWordList.Contains(KeyWord) });
|
|
||||||
|
//-------
|
||||||
|
//Add to matching keywords
|
||||||
|
//was this before tags: MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = NewWord.Id, InName = NameKeyWordList.Contains(KeyWord) });
|
||||||
|
//Name or regular word match?
|
||||||
|
bool IsName = NameKeyWordList.Contains(KeyWord);
|
||||||
|
if (IsName || KeyWordList.Contains(KeyWord))
|
||||||
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = NewWord.Id, InName = IsName });
|
||||||
|
|
||||||
|
//Tag match?
|
||||||
|
if (p.Tags.Contains(KeyWord))
|
||||||
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = NewWord.Id, InTags = true });
|
||||||
|
|
||||||
|
//-------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//It exists now
|
//It exists now
|
||||||
ExistingKeywordMatches.Add(NewWord.Id, NewWord.Word);
|
ExistingKeywordMatches.Add(NewWord.Id, NewWord.Word);
|
||||||
}
|
}
|
||||||
@@ -536,7 +555,19 @@ namespace AyaNova.Biz
|
|||||||
var SearchDictionaryMatchFoundInDB = ServiceProviderProvider.DBContext.SearchDictionary.AsNoTracking().Where(x => x.Word == KeyWord).FirstOrDefault();
|
var SearchDictionaryMatchFoundInDB = ServiceProviderProvider.DBContext.SearchDictionary.AsNoTracking().Where(x => x.Word == KeyWord).FirstOrDefault();
|
||||||
if (SearchDictionaryMatchFoundInDB != null)
|
if (SearchDictionaryMatchFoundInDB != null)
|
||||||
{
|
{
|
||||||
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = SearchDictionaryMatchFoundInDB.Id, InName = NameKeyWordList.Contains(KeyWord) });
|
//was before tags: MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = SearchDictionaryMatchFoundInDB.Id, InName = NameKeyWordList.Contains(KeyWord) });
|
||||||
|
//-------
|
||||||
|
//Add to matching keywords
|
||||||
|
//Name or regular word match?
|
||||||
|
bool IsName = NameKeyWordList.Contains(KeyWord);
|
||||||
|
if (IsName || KeyWordList.Contains(KeyWord))
|
||||||
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = SearchDictionaryMatchFoundInDB.Id, InName = IsName });
|
||||||
|
|
||||||
|
//Tag match?
|
||||||
|
if (p.Tags.Contains(KeyWord))
|
||||||
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = SearchDictionaryMatchFoundInDB.Id, InTags = true });
|
||||||
|
|
||||||
|
//-------
|
||||||
//It exists now
|
//It exists now
|
||||||
ExistingKeywordMatches.Add(SearchDictionaryMatchFoundInDB.Id, SearchDictionaryMatchFoundInDB.Word);
|
ExistingKeywordMatches.Add(SearchDictionaryMatchFoundInDB.Id, SearchDictionaryMatchFoundInDB.Word);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user