From b6e072bfdd7e714b4249d9ec09ad5738602027b3 Mon Sep 17 00:00:00 2001 From: Hendy Racher Date: Sun, 7 Apr 2019 18:10:29 +0100 Subject: [PATCH] BackOffice now has raw query for newly indexed field (to get all tags in a group) --- .../Services/QueryService.cs | 14 +++++--------- .../Services/LookService_IndexTags.cs | 2 ++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Our.Umbraco.Look.BackOffice/Services/QueryService.cs b/src/Our.Umbraco.Look.BackOffice/Services/QueryService.cs index cab6dc3..a0608fe 100644 --- a/src/Our.Umbraco.Look.BackOffice/Services/QueryService.cs +++ b/src/Our.Umbraco.Look.BackOffice/Services/QueryService.cs @@ -182,23 +182,19 @@ internal static MatchesResult GetTagMatches(string searcherName, string tagGroup { var matchesResult = new MatchesResult(); - var lookQuery = new LookQuery(searcherName); - var tagQuery = new TagQuery(); // setting a tag query, means only items that have tags will be returned + var lookQuery = new LookQuery(searcherName) { TagQuery = new TagQuery() }; if (!string.IsNullOrWhiteSpace(tagGroup) && string.IsNullOrWhiteSpace(tagName)) // only have the group to query { - var tagNames = QueryService.GetTagNames(searcherName, tagGroup); - var tags = TagQuery.MakeTags(tagNames.Select(x => tagGroup + ":" + x)); - - tagQuery.HasAny = tags; + //use raw query looking for newly indexed field(in look 0.33.0) + // TODO: update look to handle tags like "colour:*" + lookQuery.RawQuery = "Look_TagGroup_" + tagGroup + ":1"; } else if (!string.IsNullOrWhiteSpace(tagName)) // we have a specifc tag { - tagQuery.Has = new LookTag(tagGroup, tagName); + lookQuery.TagQuery.Has = new LookTag(tagGroup, tagName); } - lookQuery.TagQuery = tagQuery; - QueryService.SetSort(lookQuery, sort); var lookResult = lookQuery.Search(); diff --git a/src/Our.Umbraco.Look/Services/LookService_IndexTags.cs b/src/Our.Umbraco.Look/Services/LookService_IndexTags.cs index ea26759..e979089 100644 --- a/src/Our.Umbraco.Look/Services/LookService_IndexTags.cs +++ b/src/Our.Umbraco.Look/Services/LookService_IndexTags.cs @@ -62,6 +62,8 @@ private static void IndexTags(IndexingContext indexingContext, Document document "1", Field.Store.NO, Field.Index.NOT_ANALYZED); + + document.Add(tagGroupField); } } }