public void ParseQuery_SpecialCharacters() { var result = SearchParser.ParseQuery("\"Dancing☆Samurai\" artist-name:Gackpoid-V2"); AssertSearchWord(result, string.Empty, "Dancing☆Samurai"); AssertSearchWord(result, "artist-name", "Gackpoid-V2"); }
public void ParseQuery_KeywordWithPhrase() { var result = SearchParser.ParseQuery("artist-name:\"Hatsune Miku\" Nostalgia"); AssertSearchWord(result, "artist-name", "Hatsune Miku"); AssertSearchWord(result, string.Empty, "Nostalgia"); }
public void ParseQuery_QueryWithKeywords() { var result = SearchParser.ParseQuery("artist-name:doriko Nostalgia"); AssertSearchWord(result, "artist-name", "doriko"); AssertSearchWord(result, string.Empty, "Nostalgia"); }
private SearchTextQuery ProcessAdvancedSearch(SearchTextQuery textQuery, SongQueryParams queryParams) { if (textQuery.IsEmpty || textQuery.MatchMode == NameMatchMode.Exact || textQuery.MatchMode == NameMatchMode.StartsWith || !textQuery.OriginalQuery.StartsWith("!")) { return(textQuery); } var parsed = SearchParser.ParseQuery(textQuery.OriginalQuery.Substring(1)); var artistNames = parsed.GetValues("artist").ToArray(); if (artistNames.Any()) { queryParams.ArtistNames = artistNames; } var words = parsed.GetValues("").ToArray(); if (words.Any()) { queryParams.Common.TextQuery = new SearchTextQuery(textQuery.Query, NameMatchMode.Words, textQuery.OriginalQuery, words); return(queryParams.Common.TextQuery); } else { return(textQuery); } }
public QueryPlan <Album> BuildPlan(string query) { var words = SearchParser.ParseQuery(query); var filters = new List <ISearchFilter <Album> >(); var names = words.TakeAll(string.Empty); if (names.Any()) { filters.Add(new AlbumNameFilter(names.Select(n => n.Value))); } var artists = words.TakeAll("artist"); if (artists.Any()) { filters.Add(new AlbumArtistNameFilter(artists.Select(n => n.Value))); } while (words.Any()) { var word = words.TakeNext(); ISearchFilter <Album> filter = null; switch (word.PropertyName.ToLowerInvariant()) { case "artistId": int artistId; if (int.TryParse(word.Value, out artistId)) { filter = new AlbumArtistFilter(artistId); } break; case "tag": filter = new AlbumTagFilter(word.Value); break; default: filter = new AlbumNameFilter(new[] { word.Value }); break; } if (filter != null) { filters.Add(filter); } } return(new QueryPlan <Album>(filters)); }
public void ParseQuery_WordsAndPhrase() { var result = SearchParser.ParseQuery("\"Romeo and Cinderella\" Hatsune Miku"); AssertSearchWord(result, string.Empty, "Romeo and Cinderella", "Hatsune", "Miku"); }
public void ParseQuery_QueryWithPhrase() { var result = SearchParser.ParseQuery("\"Romeo and Cinderella\""); AssertSearchWord(result, string.Empty, "Romeo and Cinderella"); }
public void ParseQuery_MultipleWords() { var result = SearchParser.ParseQuery("Romeo and Cinderella"); AssertSearchWord(result, string.Empty, "Romeo", "and", "Cinderella"); }