public string[] FindTags(string term, int maxResults) { return(tagQueries.FindNames(TagSearchTextQuery.Create(term), true, 10)); }
public string[] FindNames(SearchTextQuery textQuery, int maxResults) { if (textQuery.IsEmpty) { return new string[] { } } ; var artistTextQuery = ArtistSearchTextQuery.Create(textQuery); var tagTextQuery = TagSearchTextQuery.Create(textQuery); return(HandleQuery(session => { var artistNames = session.Query <ArtistName>() .WhereArtistNameIs(artistTextQuery) .Where(a => !a.Artist.Deleted) .Select(n => n.Value) .OrderBy(n => n) .Distinct() .Take(maxResults) .ToArray(); var albumNames = session.Query <AlbumName>() .WhereEntryNameIs(textQuery) .Where(a => !a.Album.Deleted) .Select(n => n.Value) .OrderBy(n => n) .Distinct() .Take(maxResults) .ToArray(); var songNames = session.Query <SongName>() .WhereEntryNameIs(textQuery) .Where(a => !a.Song.Deleted) .Select(n => n.Value) .OrderBy(n => n) .Distinct() .Take(maxResults) .ToArray(); var eventNames = session.Query <EventName>() .WhereEntryNameIs(textQuery) .Where(a => !a.Entry.Deleted) .Select(t => t.Value) .OrderBy(t => t) .Take(maxResults) .ToArray(); var tagNames = session.Query <TagName>() .WhereEntryNameIs(tagTextQuery) .Where(a => !a.Entry.Deleted) .Select(t => t.Value) .OrderBy(t => t) .Take(maxResults) .ToArray(); var allNames = artistNames .Concat(albumNames) .Concat(songNames) .Concat(eventNames) .Concat(tagNames) .Distinct() .OrderBy(n => n) .Take(maxResults) .ToArray(); return NameHelper.MoveExactNamesToTop(allNames, textQuery.Query); })); }
public TagContract GetTagByName(string name) { var tag = tagQueries.Find(t => new TagContract(t, ContentLanguagePreference.Default, true), new TagQueryParams(new CommonSearchParams(TagSearchTextQuery.Create(name), false, true), new PagingProperties(0, 1, false))).Items.FirstOrDefault(); return(tag); }
public string[] GetNames( string query = "", bool allowAliases = true, int maxResults = 10) { return(queries.FindNames(TagSearchTextQuery.Create(query), allowAliases, maxResults)); }
private Tag GetTagByName(IDatabaseContext <Tag> ctx, string name) { return(ctx.Query().WhereHasName(TagSearchTextQuery.Create(name, NameMatchMode.Exact)).FirstOrDefault()); }