This commit is contained in:
2018-09-19 19:54:43 +00:00
parent c695204051
commit 97b0097582

View File

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