From d204d9f20c4019503763542d7167073f7e793419 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 21 Sep 2018 17:35:47 +0000 Subject: [PATCH] --- devdocs/todo.txt | 3 +++ server/AyaNova/biz/Search.cs | 4 +++- test/raven-integration/Search/SearchOps.cs | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index af0b5f27..69158b2c 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -35,6 +35,9 @@ IMMEDIATE ITEMS: - Add tests for searching and routes, test all variants of search including rights related stuff - 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 + - bugbug: why is the single letter a being indexed? Missing shortness filter?? + - bugbug: in searchkey an item will appear twice if the keywords appear in both the name and the text + - Update all the other routes to include search indexing (attachments, tags etc, anything with text in it) - 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/Search.cs b/server/AyaNova/biz/Search.cs index 61c47f7b..5bd4cd7c 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -173,8 +173,10 @@ namespace AyaNova.Biz //SEARCH SEARCHKEY FOR MATCHING WORDS AND OPTIONALLY TYPE AND INNAME + var TestRawMatches = await ct.SearchKey.Where(x => DictionaryMatches.Contains(x.WordId)).ToListAsync(); + //Build search query based on searchParameters - var q = ct.SearchKey.Distinct().Where(m => DictionaryMatches.Contains(m.Id)); + var q = ct.SearchKey.Distinct().Where(x => DictionaryMatches.Contains(x.WordId)); //In name? if (searchParameters.NameOnly) diff --git a/test/raven-integration/Search/SearchOps.cs b/test/raven-integration/Search/SearchOps.cs index dac80867..f0f75076 100644 --- a/test/raven-integration/Search/SearchOps.cs +++ b/test/raven-integration/Search/SearchOps.cs @@ -19,6 +19,7 @@ namespace raven_integration [Fact] public async void PhraseOnlySearchShouldWork() { + const string TEST_SEARCH_PHRASE = "simple dogs"; //CREATE A WIDGET dynamic D = new JObject(); @@ -32,8 +33,21 @@ namespace raven_integration Util.ValidateDataReturnResponseOk(a); long FirstWidgetId = a.ObjectResponse["result"]["id"].Value(); + //CREATE A SECOND WIDGET D = new JObject(); - D.name = Util.Uniquify("Search Simple SECOND Test WIDGET"); + D.name = Util.Uniquify("Search simple as in dogs SECOND Test WIDGET"); + D.dollarAmount = 1.11m; + D.active = true; + D.roles = 0; + D.notes = "This Widget should be returned in the search as it contains both keywords in the name"; + + a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); + Util.ValidateDataReturnResponseOk(a); + long SecondWidgetId = a.ObjectResponse["result"]["id"].Value(); + + //CREATE A THIRD WIDGET + D = new JObject(); + D.name = Util.Uniquify("Search Simple THIRD Test WIDGET"); D.dollarAmount = 1.11m; D.active = true; D.roles = 0; @@ -41,11 +55,12 @@ namespace raven_integration a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); Util.ValidateDataReturnResponseOk(a); - long SecondWidgetId = a.ObjectResponse["result"]["id"].Value(); + long ThirdWidgetId = a.ObjectResponse["result"]["id"].Value(); //Now see if can find that widget with a phrase search dynamic SearchParameters = new JObject(); - SearchParameters.phrase = "simple dogs"; + + SearchParameters.phrase = TEST_SEARCH_PHRASE; SearchParameters.nameOnly = false; SearchParameters.typeOnly = 0;//no type a = await Util.PostAsync("Search", await Util.GetTokenAsync("manager", "l3tm3in"), SearchParameters.ToString());