Ejemplo n.º 1
0
        public void SearchingByNameReturnsTheObjectId()
        {
            Client.Put(new RiakObject(Bucket, RiakSearchKey, RiakSearchDoc, RiakConstants.ContentTypes.ApplicationJson));
            Client.Put(new RiakObject(Bucket, RiakSearchKey2, RiakSearchDoc2, RiakConstants.ContentTypes.ApplicationJson));

            var mr = new RiakMapReduceQuery();

            var token = new RiakSearchPhraseToken("Al*");
            var solr = new SolrQuery { Fieldname = "name", QueryPart = token };

            var modFunArg = new RiakModuleFunctionArgInput
                                {
                                    Module = "riak_search",
                                    Function = "mapred_search",
                                    Arg = new[] {Bucket, solr.ToString()}
                                };

            mr.Inputs(modFunArg)
                .MapJs(m => m.Source(@"function(value, keydata, arg) { return [value]; }").Keep(true))
                .ReduceJs(r => r.Source(@"function(values, arg) { return values; }").Keep(true));

            var result = Client.MapReduce(mr);
            result.IsSuccess.ShouldBeTrue();

            var mrResult = result.Value;
            mrResult.PhaseResults.Count().ShouldEqual(2);

            mrResult.PhaseResults.ElementAt(0).Values.ShouldNotBeNull();
            mrResult.PhaseResults.ElementAt(1).Values.ShouldNotBeNull();
            // TODO Add data introspection to test - need to verify the results, after all.
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
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");
        }
Ejemplo n.º 5
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();
        }
        public void SearchingByNameUsingRiakSearchObjectReturnsTheObjectid()
        {
            Client.Put(new RiakObject(Bucket, RiakSearchKey, RiakSearchDoc, RiakConstants.ContentTypes.ApplicationJson));
            Client.Put(new RiakObject(Bucket, RiakSearchKey2, RiakSearchDoc2, RiakConstants.ContentTypes.ApplicationJson));

            var mr = new RiakMapReduceQuery();

            //var rspt = new RiakSearchPhraseToken {Field = "name", Term = "Al*"};
            var rspt = new RiakSearchPhraseToken("Al*");

            var mfa = new RiakModuleFunctionArgInput
                          {
                              Module = "riak_search",
                              Function = "mapred_search",
                              Arg = new[] {Bucket, rspt.ToString()}
                          };

            mr.Inputs(mfa);

            var result = Client.MapReduce(mr);
            result.IsSuccess.ShouldBeTrue();

            var mrResult = result.Value;
            mrResult.PhaseResults.Count().ShouldEqual(1);

            mrResult.PhaseResults.ElementAt(0).Values.ShouldNotBeNull();
        }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
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();
        }