From c695204051b967ea3cbb89e63b6accab16545628 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 19 Sep 2018 19:49:43 +0000 Subject: [PATCH] --- devdocs/specs/core-search.txt | 25 ++++++++++----- devdocs/todo.txt | 2 ++ server/AyaNova/biz/AyaType.cs | 2 +- server/AyaNova/biz/Search.cs | 59 ++++++++++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 9 deletions(-) diff --git a/devdocs/specs/core-search.txt b/devdocs/specs/core-search.txt index 8cb0e4ae..cc919b8f 100644 --- a/devdocs/specs/core-search.txt +++ b/devdocs/specs/core-search.txt @@ -4,8 +4,9 @@ SEARCH SPECS CASES -SEARCH: - to have ability to filter by client -https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/1503 +//NOPE: this one deprecated to priority 2, not really required and may be problematic +//SEARCH: - to have ability to filter by client +//https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/1503 SEARCH:UI:GENERAL: - Search in V8: should be integrated, not a separate form https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/1672 @@ -32,8 +33,12 @@ https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3506 REQUIREMENTS -- USE-CASE: Central text search for any match. Can include tags. Can specify a type of object. -- USE-CASE: In-object text search for the typeandid that user is in, e.g. when in Client info form can search on that client. +- USE-CASE: Central text search for any match. Can include tags. Can specify a type of object result desired. + +- ? USE-CASE: In-object text search for the typeandid that user is in, e.g. when in Client info form can search on that client. + - This is problematic because it seems to require searching for related objects but that's deprecated to priority 2 + - Maybe more ideally is a search that can be something like "search all workorders FOR THIS CLIENT" or search all units "FOR THIS CLIENT" + - USE-CASE: Picklist / chooser Search for text of a specific type of object, e.g. find all Clients that contain "squirrel" to drive picklists everywhere - USE-CASE: No snippet (excerpts) just name and type. I think for the initial release I'm *not* going to include snippets with result for several reasons: - Performance: better to get an immediate result than to wait a while to get excerpts that @@ -48,14 +53,20 @@ REQUIREMENTS - ROLES: Needs to internally be able to filter by CANREAD property of role user is in (e.g. if no rights to read client no clients returned) - INDEX VISIBLE ID NUMBERS MUST be searchable so ensure they get put into text search with the regular text. -- OBJECT ID and/or OBJECT TYPE criteria support (AyaTypeId must be included in search index) -- PARENT / OPENABLE OBJECT: Objects that are searchable but not openable directly need to contain their parent type and id, this way we can follow a chain to the openeable object if necessary +- OBJECT TYPE criteria support (AyaType must be included in search index) + +- CLIENT_NOT_SERVER_REQUIREMENT: PARENT / OPENABLE OBJECT: Objects that are searchable but not openable directly will be handled by the client + - Maybe this is a client concern, not a backend concern as pre-finding all the parents at the backend for the results is slower than + dynamically pulling it for one being opened from the client - This is in the object, not in the searchkey as it would be inefficient - - Need parent AyaType as an ENUM ATTRIBUTE in the AyaType table for easy traversal + - Maybe need parent AyaType as an ENUM ATTRIBUTE in the AyaType table for easy traversal? + - CLEANUP: Generator able to cleanup index with no matching word (if possible), index with no matching typeandid - CJK INDEX support: same as v7 but tied to Locale, not globally - GROUP BY: group by objectype then objectid (then created date?) - Coding: break this into separate discrete classes, the old v7 code is very monolithic and in-elegant + +//TODO: - SAMPLE DATA: Need a huge amount of sample data indexed to load test it - INDEXES: play with it and see what works best diff --git a/devdocs/todo.txt b/devdocs/todo.txt index ca449a2b..0d1ebaa6 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -33,6 +33,8 @@ IMMEDIATE ITEMS: - Add tests using widget which now sports a Notes property - Add code to do actual search and return results and routes (tags need support too as per search specs) - Add tests for searching and routes + - Update all the seeder code to add search indexing so can properly test huge search datasets + - Need to find a way to add random text to Notes fields that varies but has some overlap ideally - EventLogProcessor.AddEntry: CHANGE this to save the context itself and then change all callers to handle that (remove save) - I originally didn't have the save in there because I thought subsequent code might all share in the single context save, diff --git a/server/AyaNova/biz/AyaType.cs b/server/AyaNova/biz/AyaType.cs index 1c58201b..6fb0bf62 100644 --- a/server/AyaNova/biz/AyaType.cs +++ b/server/AyaNova/biz/AyaType.cs @@ -9,7 +9,7 @@ namespace AyaNova.Biz /// public enum AyaType : int { - NotValid = 0, + NoType = 0, Global = 1, [Attachable, Taggable] diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index f5789076..9668b4e6 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -28,6 +28,60 @@ namespace AyaNova.Biz #region Search and return results + +/* +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 + + +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 + +result:[ +{ + name:"blah", + type:2, + id:210 +}, +] + + + */ + +//Class to hold search request parameters + public class SearchRequestParameter + { + public string Phrase {get;set;} + public bool NameOnly { get; set; } + public AyaType TypeOnly {get;set;} + public List Tags { get; set; } + + public SearchRequestParameter() + { + NameOnly = false; + TypeOnly=AyaType. + Tags = new List(); + } + } + + //Class to hold search result public class SearchResult { @@ -40,12 +94,15 @@ namespace AyaNova.Biz } } + + + public static async Task> DoSearch(AyContext ct, long localeId, long objectID, AyaType objectType, string name, params string[] text) { List ResultList=new List(); //fake await to clear error -await ct.SaveChangesAsync(); +//await ct.SaveChangesAsync(); return ResultList; }