Beispiel #1
0
        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");
        }
Beispiel #2
0
        public void ParseQuery_KeywordWithPhrase()
        {
            var result = SearchParser.ParseQuery("artist-name:\"Hatsune Miku\" Nostalgia");

            AssertSearchWord(result, "artist-name", "Hatsune Miku");
            AssertSearchWord(result, string.Empty, "Nostalgia");
        }
Beispiel #3
0
        public void ParseQuery_QueryWithKeywords()
        {
            var result = SearchParser.ParseQuery("artist-name:doriko Nostalgia");

            AssertSearchWord(result, "artist-name", "doriko");
            AssertSearchWord(result, string.Empty, "Nostalgia");
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        public void ParseQuery_WordsAndPhrase()
        {
            var result = SearchParser.ParseQuery("\"Romeo and Cinderella\" Hatsune Miku");

            AssertSearchWord(result, string.Empty, "Romeo and Cinderella", "Hatsune", "Miku");
        }
Beispiel #7
0
        public void ParseQuery_QueryWithPhrase()
        {
            var result = SearchParser.ParseQuery("\"Romeo and Cinderella\"");

            AssertSearchWord(result, string.Empty, "Romeo and Cinderella");
        }
Beispiel #8
0
        public void ParseQuery_MultipleWords()
        {
            var result = SearchParser.ParseQuery("Romeo and Cinderella");

            AssertSearchWord(result, string.Empty, "Romeo", "and", "Cinderella");
        }