From f27e80131785f77b90c6ddc64e585d8559cac046 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 21 Sep 2018 18:30:18 +0000 Subject: [PATCH] --- server/AyaNova/biz/Search.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index d7d4ecf6..2246a26a 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -172,8 +172,9 @@ namespace AyaNova.Biz } //SEARCH SEARCHKEY FOR MATCHING WORDS AND OPTIONALLY TYPE AND INNAME + var TotalSearchTermsToMatch = WildCardSearchTerms.Count + RegularSearchTerms.Count; - var TestRawMatches = await ct.SearchKey.Where(x => DictionaryMatches.Contains(x.WordId)).ToListAsync(); + // var TestRawMatches = await ct.SearchKey.Where(x => DictionaryMatches.Contains(x.WordId)).ToListAsync(); //Build search query based on searchParameters var q = ct.SearchKey.Distinct().Where(x => DictionaryMatches.Contains(x.WordId)); @@ -188,15 +189,15 @@ namespace AyaNova.Biz - //Find the records that have all the words - //BUGBUG: IT'S FINDING WIDGET 203 WHICH ONLY HAS ONE OF THE WORDS, IS THIS DOING WHAT I THINK IT'S DOING? + //Find the records that have the search terms in searchkey var SearchMatches = q.GroupBy(x => new { x.ObjectType, x.ObjectId }).Select(x => new { ObjectId = x.Key.ObjectId, ObjectType = x.Key.ObjectType, ObjectCount = x.LongCount() }); //PUT THE RESULTS INTO MATCHING OBJECTS LIST foreach (var SearchMatch in SearchMatches) { - //BUGBUG: Shouldn't this going to require checking the count?? - MatchingObjects.Add(new AyaTypeId(SearchMatch.ObjectType, SearchMatch.ObjectId)); + //keep any object that matches *all* the search terms + if (SearchMatch.ObjectCount == TotalSearchTermsToMatch) + MatchingObjects.Add(new AyaTypeId(SearchMatch.ObjectType, SearchMatch.ObjectId)); }