diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 3571a259..9d68e2cc 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -185,18 +185,23 @@ namespace AyaNova.Biz if (searchParameters.TypeOnly != AyaType.NoType) q.Where(m => m.ObjectType == searchParameters.TypeOnly); - //Trigger the search - SearchKeyMatches = await q.ToListAsync(); - BUGBUG: the current simple phrase search test is returning records when only one of the two search words matches "simple dogs" -//However only one widget created in the test has both words, teh other only has one and should not return a result -//Need to rejig this so only if all words are matching does it consider it a hit + + var SearchMatches = q.GroupBy(x => new { x.ObjectType, x.ObjectId }).Select(x => new { ObjectId = x.Key.ObjectId, ObjectType = x.Key.ObjectType, ObjectCount = x.LongCount() }); + foreach (var SearchMatch in SearchMatches) + { + MatchingObjects.Add(new AyaTypeId(SearchMatch.ObjectType, SearchMatch.ObjectId)); + } + //Trigger the search + // SearchKeyMatches = await q.ToListAsync(); + + // need to group by object type and id and count instead? //PUT THE RESULTS INTO MATCHING OBJECTS LIST - foreach (SearchKey SearchKeyMatch in SearchKeyMatches) - { - MatchingObjects.Add(new AyaTypeId(SearchKeyMatch.ObjectType, SearchKeyMatch.ObjectId)); - } + // foreach (SearchKey SearchKeyMatch in SearchKeyMatches) + // { + // MatchingObjects.Add(new AyaTypeId(SearchKeyMatch.ObjectType, SearchKeyMatch.ObjectId)); + // } //IF TAGS SPECIFIED