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. }
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 modFunArg = new RiakModuleFunctionArgInput { Module = "riak_search", Function = "mapred_search", Arg = new[] {Bucket, "name:Al*"} }; mr.Inputs(modFunArg); var result = Client.MapReduce(mr); result.IsSuccess.ShouldBeTrue(); var mrResult = result.Value; mrResult.PhaseResults.Count().ShouldEqual(1); mrResult.PhaseResults.ElementAt(0).Values.ShouldNotBeNull(); // TODO Add data introspection to test - need to verify the results, after all. }
public RiakMapReduceQuery Inputs(RiakModuleFunctionArgInput riakModFunArgsInput) { _inputs = riakModFunArgsInput; return this; }
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(); }