예제 #1
0
        public void SolrTermCorrectlyEscapesMultipleSpecialCharacters()
        {
            var token = new RiakSearchToken();
            var spt = new RiakSearchPhraseToken("2+2-2");
            token.Term = spt;

            string escapedString = token.ToString();

            escapedString.Contains(@"\").ShouldBeTrue();
            escapedString.Equals(@"2\+2\-2").ShouldBeTrue();
        }
예제 #2
0
        public void BoostedPhrasesShouldContainACaretOutsideOfQuotedString()
        {
            var token = new RiakSearchToken {Field = "artist", Boost = 10};
            var spt = new RiakSearchPhraseToken("The Rolling Stones");

            token.Term = spt;

            string result = token.ToString();

            result.Contains("^").ShouldBeTrue();
            result.ShouldEqual(@"artist:""The Rolling Stones""^10");
        }
예제 #3
0
        public void BoostedTermsShouldContainACaret()
        {
            var token = new RiakSearchToken {Boost = 10};
            var spt = new RiakSearchPhraseToken("Erlang");

            token.Term = spt;

            string result = token.ToString();

            result.Contains("^").ShouldBeTrue();
            result.Equals("Erlang^10").ShouldBeTrue();
        }
예제 #4
0
        public void RequiredTermsShouldBePrefixedWithAPlusSign()
        {
            var token = new RiakSearchToken {Required = true};

            var spt = new RiakSearchPhraseToken("riak");

            token.Term = spt;

            string result = token.ToString();

            result.Contains("+").ShouldBeTrue();
            result.Equals("+riak").ShouldBeTrue();
        }
예제 #5
0
        public void ExclusiveTermShouldBeFormattedCorrecly()
        {
            var token = new RiakSearchToken {Field = "title"};
            var srt = new RiakSearchRangeToken {From = "Aida", To = "Carmen", Inclusive = false};

            token.Term = srt;

            token.Term.ToSearchTerm().ShouldEqual("{Aida TO Carmen}");
            token.ToString().ShouldEqual("title:{Aida TO Carmen}");
        }
예제 #6
0
        public void InclusiveTermShouldBeFormattedCorrecly()
        {
            var token = new RiakSearchToken();
            var srt = new RiakSearchRangeToken {From = "20020101", To = "20030101", Inclusive = true};

            token.Field = "mod_date";
            token.Term = srt;

            token.Term.ToSearchTerm().ShouldEqual("[20020101 TO 20030101]");
            token.ToString().ShouldEqual("mod_date:[20020101 TO 20030101]");
        }
예제 #7
0
        public void OrTokensAreFormattedCorrectly()
        {
            var first = new RiakSearchToken {Term = new RiakSearchPhraseToken("coffee")};
            var second = new RiakSearchToken {Term = new RiakSearchPhraseToken("tea")};
            var or = new Or(first, second);

            var result = or.ToString();

            result.Contains("OR").ShouldBeTrue();
            result.ShouldEqual("coffee OR tea");
        }
예제 #8
0
        public void GroupTokensAreFormattedCorrectly()
        {
            var first = new RiakSearchToken {Term = new RiakSearchPhraseToken("coffee")};
            var second = new RiakSearchToken {Term = new RiakSearchPhraseToken("tea")};
            var or = new Or(first, second);

            var g = new Group();
            g.AddItem(or);

            string result = g.ToString();

            result.Contains("OR").ShouldBeTrue();
            result.ShouldEqual("(coffee OR tea)");
        }
예제 #9
0
        public void AndTokensAreFormattedCorrectly()
        {
            var first = new RiakSearchToken {Term = new RiakSearchPhraseToken("coffee")};
            var second = new RiakSearchToken {Term = new RiakSearchPhraseToken("tea")};
            var and = new And(first, second);

            var result = and.ToString();

            result.Contains("AND").ShouldBeTrue();
            result.ShouldEqual("coffee AND tea");
        }
예제 #10
0
        public void SolrTermWithSpacesShouldBeQuoted()
        {
            var token = new RiakSearchToken {Field = "artist"};

            var spt = new RiakSearchPhraseToken("The Rolling Stones");

            token.Term = spt;

            string result = token.ToString();

            result.Equals(@"artist:""The Rolling Stones""").ShouldBeTrue();
        }
예제 #11
0
        public void SolrTermIncludesFieldName()
        {
            var token = new RiakSearchToken {Field = "eyes"};
            var spt = new RiakSearchPhraseToken("blue");
            token.Term = spt;

            string result = token.ToString();

            result.Contains("eyes").ShouldBeTrue();
            result.Contains("blue").ShouldBeTrue();
            result.Equals("eyes:blue").ShouldBeTrue();
        }