diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 9668b4e6..332191ae 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -29,84 +29,98 @@ namespace AyaNova.Biz #region Search and return results -/* -Requirements: + /* + Requirements: -INPUT PARAMETERS -- Search phrase (with wildcard support) - - Can be empty if tags are specified, no tags and no phrase is an error condition -- ObjectType: only return results for objects of this type -- InName: flag that indicates only search in names -- Tag ids that are also on result objects - - Can be empty if a phrase is specified + INPUT PARAMETERS + - Search phrase (with wildcard support) + - Can be empty if tags are specified, no tags and no phrase is an error condition + - ObjectType: only return results for objects of this type + - InName: flag that indicates only search in names + - Tag ids that are also on result objects + - Can be empty if a phrase is specified -ACTION -Find search matches, then find tag matches then intersect, then sort and return -Filter OUT results that user is not permitted to read -//TODO: proper testing of searching -- SAMPLE DATA: Need a huge amount of sample data indexed to load test it -- INDEXES: play with it and see what works best + ACTION + Find search matches, then find tag matches then intersect, then sort and return + Filter OUT results that user is not permitted to read + //TODO: proper testing of searching + - SAMPLE DATA: Need a huge amount of sample data indexed to load test it + - INDEXES: play with it and see what works best -OUTPUT FORMAT -- No localized text, up to client -- Name of object in return result -- Object Type and ID in return result -- Group results by object type, then by object ID descending which will result in natural most recently created order + OUTPUT FORMAT + - No localized text, up to client + - Name of object in return result + - Object Type and ID in return result + - Group results by object type, then by object ID descending which will result in natural most recently created order -result:[ -{ - name:"blah", - type:2, - id:210 -}, -] - - - */ - -//Class to hold search request parameters - public class SearchRequestParameter + result:[ { - public string Phrase {get;set;} + name:"blah", + type:2, + id:210 + }, + ] + + + */ + + //Class to hold search request parameters + public class SearchRequestParameters + { + public string Phrase { get; set; } public bool NameOnly { get; set; } - public AyaType TypeOnly {get;set;} + public AyaType TypeOnly { get; set; } public List Tags { get; set; } - public SearchRequestParameter() + public SearchRequestParameters() { NameOnly = false; - TypeOnly=AyaType. + TypeOnly = AyaType.NoType; Tags = new List(); } + + public bool IsValid + { + get + { + //has a phrase? + if (!string.IsNullOrWhiteSpace(this.Phrase)) + return true; + + //has tags? + if (this.Tags.Count > 0) + return true; + + return false; + } + } } //Class to hold search result public class SearchResult { - public bool CJKIndex { get; set; } - public List StopWords { get; set; } - public SearchResult() - { - CJKIndex = false; - StopWords = new List(); - } + public string Name { get; set; } + public AyaType Type { get; set; } + public long Id { get; set; } } - public static async Task> DoSearch(AyContext ct, long localeId, long objectID, AyaType objectType, string name, params string[] text) + public static async Task> DoSearch(AyContext ct, SearchRequestParameters searchParameters) { - List ResultList=new List(); + List ResultList = new List(); -//fake await to clear error -//await ct.SaveChangesAsync(); + //fake await to clear error + //await ct.SaveChangesAsync(); - return ResultList; + return ResultList; } - #endregion + + + #endregion dosearch #region ProcessKeywords into Database