|
|
|
|
@@ -65,7 +65,7 @@ namespace AyaNova.Biz
|
|
|
|
|
public string Phrase { get; set; }
|
|
|
|
|
public bool NameOnly { get; set; }
|
|
|
|
|
public AyaType TypeOnly { get; set; }
|
|
|
|
|
// public List<long> Tags { get; set; }
|
|
|
|
|
// public List<long> Tags { get; set; }
|
|
|
|
|
//Note: maxresults of 0 will get all results
|
|
|
|
|
public int MaxResults { get; set; }
|
|
|
|
|
|
|
|
|
|
@@ -73,7 +73,7 @@ namespace AyaNova.Biz
|
|
|
|
|
{
|
|
|
|
|
NameOnly = false;
|
|
|
|
|
TypeOnly = AyaType.NoType;
|
|
|
|
|
// Tags = new List<long>();
|
|
|
|
|
// Tags = new List<long>();
|
|
|
|
|
MaxResults = 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -213,7 +213,7 @@ namespace AyaNova.Biz
|
|
|
|
|
|
|
|
|
|
//IF TAGS SPECIFIED
|
|
|
|
|
//BUGBUG: If no valid tags provided, i.e. a single tag of type or id 0 then can skip
|
|
|
|
|
// if (searchParameters.Tags.Count > 0)
|
|
|
|
|
// if (searchParameters.Tags.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// //get a count of the search tags (used by both paths below)
|
|
|
|
|
// var SearchTagCount = searchParameters.Tags.Count;
|
|
|
|
|
@@ -375,14 +375,50 @@ namespace AyaNova.Biz
|
|
|
|
|
|
|
|
|
|
#region ProcessKeywords into Database
|
|
|
|
|
|
|
|
|
|
public static void ProcessNewObjectKeywords(long localeId, long objectID, AyaType objectType, string name, params string[] text)
|
|
|
|
|
//Class to hold process input parameters
|
|
|
|
|
public class SearchIndexProcessObjectParameters
|
|
|
|
|
{
|
|
|
|
|
ProcessKeywords(localeId, objectID, objectType, true, name, text);
|
|
|
|
|
public long LocaleId { get; set; }
|
|
|
|
|
public long ObjectId { get; set; }
|
|
|
|
|
public AyaType ObjectType { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public List<string> Words { get; set; }
|
|
|
|
|
public List<string> Tags { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SearchIndexProcessObjectParameters(long localeId, long objectID, AyaType objectType, string name)
|
|
|
|
|
{
|
|
|
|
|
Words = new List<string>();
|
|
|
|
|
Tags = new List<string>();
|
|
|
|
|
LocaleId = localeId;
|
|
|
|
|
ObjectId = objectID;
|
|
|
|
|
ObjectType = objectType;
|
|
|
|
|
Name = name;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SearchIndexProcessObjectParameters AddWord(string s)
|
|
|
|
|
{
|
|
|
|
|
Words.Add(s);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
public SearchIndexProcessObjectParameters AddWord(uint u)
|
|
|
|
|
{
|
|
|
|
|
Words.Add(u.ToString());
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ProcessUpdatedObjectKeywords(long localeId, long objectID, AyaType objectType, string name, params string[] text)
|
|
|
|
|
|
|
|
|
|
public static void ProcessNewObjectKeywords(SearchIndexProcessObjectParameters searchIndexObjectParameters)//(long localeId, long objectID, AyaType objectType, string name, params string[] text)
|
|
|
|
|
{
|
|
|
|
|
ProcessKeywords(localeId, objectID, objectType, false, name, text);
|
|
|
|
|
ProcessKeywords(searchIndexObjectParameters, true);//localeId, objectID, objectType, true, name, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ProcessUpdatedObjectKeywords(SearchIndexProcessObjectParameters searchIndexObjectParameters)// localeId, long objectID, AyaType objectType, string name, params string[] text)
|
|
|
|
|
{
|
|
|
|
|
ProcessKeywords(searchIndexObjectParameters, false);//localeId, objectID, objectType, false, name, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ProcessDeletedObjectKeywords(long objectID, AyaType objectType)
|
|
|
|
|
@@ -398,14 +434,14 @@ namespace AyaNova.Biz
|
|
|
|
|
/// Process the keywords into the dictionary
|
|
|
|
|
/// NOTE: NAME parameter is in ADDITION to the NAME also being on of the strings passed in text parameter
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void ProcessKeywords(long localeId, long objectID, AyaType objectType, bool newRecord, string name, params string[] text)
|
|
|
|
|
private static void ProcessKeywords(SearchIndexProcessObjectParameters p, bool newRecord)//long localeId, long objectID, AyaType objectType, string name, params string[] text)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//AyContext ct = ServiceProviderProvider.DBContext;
|
|
|
|
|
#if (DEBUG)
|
|
|
|
|
if ( objectType == AyaType.JobOperations || objectType == AyaType.Locale)
|
|
|
|
|
if (p.ObjectType == AyaType.JobOperations || p.ObjectType == AyaType.Locale)
|
|
|
|
|
{
|
|
|
|
|
throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {objectType}");
|
|
|
|
|
throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
@@ -413,17 +449,17 @@ namespace AyaNova.Biz
|
|
|
|
|
//IF NOT NEW, DELETE ALL EXISTING ENTRIES FOR OBJECT TYPE AND ID
|
|
|
|
|
if (!newRecord)
|
|
|
|
|
{
|
|
|
|
|
ProcessDeletedObjectKeywords(objectID, objectType);
|
|
|
|
|
ProcessDeletedObjectKeywords(p.ObjectId, p.ObjectType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//BREAK STRING ARRAY INTO KEYWORD LIST
|
|
|
|
|
List<string> KeyWordList = Break(localeId, text);
|
|
|
|
|
|
|
|
|
|
//BREAK OBJECT TEXT STRINGS INTO KEYWORD LIST
|
|
|
|
|
List<string> KeyWordList = Break(p.LocaleId, p.Words);
|
|
|
|
|
|
|
|
|
|
//BREAK NAME STRING
|
|
|
|
|
List<string> NameKeyWordList = Break(localeId, name);
|
|
|
|
|
List<string> NameKeyWordList = Break(p.LocaleId, p.Name);
|
|
|
|
|
|
|
|
|
|
//EARLY EXIT IF NO KEYWORDS OR NAME RECORD TO PROCESS
|
|
|
|
|
if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(name))
|
|
|
|
|
//EARLY EXIT IF NO KEYWORDS OR NAME RECORD OR TAGS TO PROCESS
|
|
|
|
|
if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(p.Name) && p.Tags.Count==0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -521,7 +557,7 @@ namespace AyaNova.Biz
|
|
|
|
|
var NewSearchKeyList = new List<SearchKey>();
|
|
|
|
|
foreach (MatchingDictionaryEntry E in MatchingKeywordIdList)
|
|
|
|
|
{
|
|
|
|
|
NewSearchKeyList.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, ObjectId = objectID, ObjectType = 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);
|
|
|
|
|
@@ -529,18 +565,18 @@ namespace AyaNova.Biz
|
|
|
|
|
|
|
|
|
|
//---------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//eoc
|
|
|
|
|
|
|
|
|
|
//Class to hold temporary list of matching id
|
|
|
|
|
public class MatchingDictionaryEntry
|
|
|
|
|
{
|
|
|
|
|
public bool InName { get; set; }
|
|
|
|
|
public bool InTags { get; set; }
|
|
|
|
|
public long DictionaryId { get; set; }
|
|
|
|
|
public MatchingDictionaryEntry()
|
|
|
|
|
{
|
|
|
|
|
InName = false;
|
|
|
|
|
InTags=false;
|
|
|
|
|
DictionaryId = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -609,11 +645,24 @@ namespace AyaNova.Biz
|
|
|
|
|
/// </summary>
|
|
|
|
|
///
|
|
|
|
|
/// <param name="localeId"></param>
|
|
|
|
|
/// <param name="text">An array of 0 to * strings of text</param>
|
|
|
|
|
/// <param name="textStrings">A stringlist of 0 to * strings of text</param>
|
|
|
|
|
/// <returns>List of strings</returns>
|
|
|
|
|
internal static List<string> Break(long localeId, params string[] text)
|
|
|
|
|
internal static List<string> Break(long localeId, List<string> textStrings)// params string[] text)
|
|
|
|
|
{
|
|
|
|
|
return BreakCore(localeId, false, text);
|
|
|
|
|
return BreakCore(localeId, false, textStrings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="localeId"></param>
|
|
|
|
|
/// <param name="textString"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal static List<string> Break(long localeId, string textString)// params string[] text)
|
|
|
|
|
{
|
|
|
|
|
List<string> textStrings = new List<string>(1);
|
|
|
|
|
textStrings.Add(textString);
|
|
|
|
|
return BreakCore(localeId, false, textStrings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@@ -621,11 +670,11 @@ namespace AyaNova.Biz
|
|
|
|
|
/// cards entered
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="localeId"></param>
|
|
|
|
|
/// <param name="text"></param>
|
|
|
|
|
/// <param name="textStrings"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal static List<string> BreakSearchPhrase(long localeId, params string[] text)
|
|
|
|
|
internal static List<string> BreakSearchPhrase(long localeId, List<string> textStrings)
|
|
|
|
|
{
|
|
|
|
|
return BreakCore(localeId, true, text);
|
|
|
|
|
return BreakCore(localeId, true, textStrings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@@ -634,7 +683,7 @@ namespace AyaNova.Biz
|
|
|
|
|
/// </summary>
|
|
|
|
|
// public static System.Collections.Generic.List<string> StopList = null;
|
|
|
|
|
|
|
|
|
|
internal static List<string> BreakCore(long localeId, bool KeepWildCards, params string[] text)
|
|
|
|
|
internal static List<string> BreakCore(long localeId, bool KeepWildCards, List<string> textStrings)
|
|
|
|
|
{
|
|
|
|
|
//Get stopwords and CJKIndex flag value
|
|
|
|
|
LocaleWordBreakingData LocaleSearchData = GetLocaleSearchData(localeId);
|
|
|
|
|
@@ -651,7 +700,7 @@ namespace AyaNova.Biz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Loop through each of the passed in strings
|
|
|
|
|
foreach (string s in text)
|
|
|
|
|
foreach (string s in textStrings)
|
|
|
|
|
{
|
|
|
|
|
if (s == null || s == "") continue;
|
|
|
|
|
//get all the characters in a unicode compliant manner...
|
|
|
|
|
|