Skip to content

Commit

Permalink
BackOffice now has raw query for newly indexed field (to get all tags…
Browse files Browse the repository at this point in the history
… in a group)
  • Loading branch information
Hendy committed Apr 7, 2019
1 parent b7ac540 commit b6e072b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Our.Umbraco.Look.BackOffice/Services/QueryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/Our.Umbraco.Look/Services/LookService_IndexTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ private static void IndexTags(IndexingContext indexingContext, Document document
"1",
Field.Store.NO,
Field.Index.NOT_ANALYZED);

document.Add(tagGroupField);
}
}
}
Expand Down

0 comments on commit b6e072b

Please sign in to comment.