public void SimpleUnaryTermWithProximitySerializesCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Proximity(5, "foo", "bar", "baz")
         .Build();
     var q = s.ToString();
     Assert.AreEqual(@"key:""foo bar baz""~5", q);
 }
 public void SimpleRangeTermSerializesCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Between("10", "20", false)
         .Build();
     var q = s.ToString();
     Assert.AreEqual("key:{10 TO 20}", q);
 }
 public void SimpleIndexFieldUnaryTermSerializesCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "field")
         .Search("foo")
         .Build();
     var q = s.ToString();
     Assert.AreEqual("field:foo", q);
 }
 public void SimpleUnaryTermWithBoostSerializesCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Search("foo")
         .Boost(5)
         .Build();
     var q = s.ToString();
     Assert.AreEqual("key:foo^5", q);
 }
 public void SimpleAndTermSerializesCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Search("foo")
         .And("bar")
         .Build();
     var q = s.ToString();
     Assert.AreEqual("key:foo AND key:bar", q);
 }
        public void ValueTextEscapedCorrectly()
        {
            var search = new RiakFluentSearch("bucket", "key")
                .Search(@"This is\ a ""Test"" to make 'sure' it (the text) is [characterised] correctly (master:slave) + includes - this url: http://foo.com/bar?baz=quux")
                .Build();

            var query = search.ToString();

            var expected = @"key:This\ is\\\ a\ \""Test\""\ to\ make\ \'sure\'\ it\ \(the\ text\)\ is\ \[characterised\]\ correctly\ \(master\:slave\)\ \+\ includes\ \-\ this\ url\:\ http\:\/\/foo.com\/bar\?baz=quux";
            Assert.AreEqual(expected, query);
        }
        public void SearchingViaFluentSearchObjectWorks()
        {
            Client.Put(new RiakObject(Bucket, RiakSearchKey, RiakSearchDoc, RiakConstants.ContentTypes.ApplicationJson));
            Client.Put(new RiakObject(Bucket, RiakSearchKey2, RiakSearchDoc2, RiakConstants.ContentTypes.ApplicationJson));

            var search = new RiakFluentSearch(Bucket, "name").Search(Token.StartsWith("A1")).Build();
            var mr = new RiakMapReduceQuery()
                .Inputs(new RiakBucketSearchInput(search));

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

            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.
        }
示例#8
0
 protected Term(RiakFluentSearch search, string field)
 {
     Search = search;
     _field = field;
 }
 public RiakBucketSearchInput Filter(RiakFluentSearch filter)
 {
     return Filter(filter.ToString());
 }
示例#10
0
 public ProximityTerm(RiakFluentSearch search, string field, double proximity, params string[] words)
     : base(search, field)
 {
     _words = new List<Token>(words.Select(Token.Is));
     _proximity = proximity;
 }
示例#11
0
 public ProximityTerm(RiakFluentSearch search, string field, double proximity, params string[] words)
     : base(search, field)
 {
     _words     = new List <Token>(words.Select(Token.Is));
     _proximity = proximity;
 }
 public RiakBucketSearchInput(RiakFluentSearch query)
     : this(query.Bucket, query.ToString())
 {
 }
示例#13
0
 public void SimpleOrAndTermWithBoostSerializesCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Search("foo")
         .Or("bar").Boost(3)
         .And("baz").Boost(5)
         .Build();
     var q = s.ToString();
     Assert.AreEqual("key:foo OR key:bar^3 AND key:baz^5", q);
 }
示例#14
0
 protected Term(RiakFluentSearch search, string field)
 {
     Search = search;
     _field = field;
 }
示例#15
0
 public void InitialGroupedTermsSerializeCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Group("foo", t => t.Or("bar").And("baz", x => x.And("schmoopy")))
         .Or("bar", t => t.And("slop"))
         .Build();
     var q = s.ToString();
     Assert.AreEqual("key:(key:foo OR key:bar AND (key:baz AND key:schmoopy)) OR (key:bar AND key:slop)", q);
 }
示例#16
0
 public void GroupedNotTermsSerializeCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Search("foo")
         .Or("bar").Not()
         .And("baz", t => t.Or("quux")).Not()
         .Or("baz", t => t.And("schmoopy")
             .Boost(6)
             .And("dooby", x => x.Or("fooby").Not()))
         .Build();
     var q = s.ToString();
     Assert.AreEqual("key:foo OR NOT key:bar AND NOT (key:baz OR key:quux) OR (key:baz AND key:schmoopy^6 AND (key:dooby OR NOT key:fooby))", q);
 }
        public void SettingSearchOnRiakBucketMakesBucketSearchable()
        {
            var bucket = string.Format("{0}_{1}", Bucket, Guid.NewGuid());
            var key = Guid.NewGuid().ToString();
            var props = Client.GetBucketProperties(bucket);
            props.SetSearch(true);

            var setResult = Client.SetBucketProperties(bucket, props);
            setResult.ShouldBeTrue();

            var obj = new RiakObject(bucket, key, new { name = "OJ", age = 34 });
            var putResult = Client.Put(obj);
            putResult.ShouldNotBeNull();

            var q = new RiakFluentSearch(bucket, "name")
                .Search("OJ")
                .And("age", "34")
                .Build();

            var search = new RiakSearchRequest
            {
                Query = q
            };

            var searchResult = Client.Search(search);
            searchResult.ShouldNotBeNull();
            searchResult.NumFound.ShouldEqual(1u);
            searchResult.Documents[0].Fields.Count.ShouldEqual(3);
            searchResult.Documents[0].Fields.First(x => x.Key == "id").Value.ShouldEqual(key);
        }
示例#18
0
 public void ComplicatedTermsSerializeCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Search("foo")
         .Or("bar").Not()
         .AndBetween("10", "20")
         .And("baz", t => t.Or("quux").OrBetween("la", "da", false)).Not()
         .AndProximity(3, "testing", "these words")
         .Or("baz", t => t.And("schmoopy for president+")
             .Boost(6)
             .And(Token.StartsWith("dooby"), x => x.Or("fooby").Not()))
         .Build();
     var q = s.ToString();
     Assert.AreEqual(@"key:foo OR NOT key:bar AND key:[10 TO 20] AND NOT (key:baz OR key:quux OR key:{la TO da}) AND key:""testing these\ words""~3 OR (key:baz AND key:schmoopy\ for\ president\+^6 AND (key:dooby* OR NOT key:fooby))", q);
 }
示例#19
0
 public void ComplicatedTermsWithExtraFieldsSerializeCorrectly()
 {
     var s = new RiakFluentSearch("bucket", "key")
         .Search("foo")
         .Or("bar").Not()
         .AndBetween("10", "20", true)
         .Or("otherkey", "baz", t => t.And("hash", Token.StartsWith("schmoopy for president+"))
             .Boost(6)
             .And("bash", "dooby", x => x.Or("dash", "fooby").Not())
             .Or("smelly"))
         .And("baz", t => t.Or("zoom", "quux").OrBetween("la", "da", false)).Not()
         .OrProximity("lala", 10, "wouldn't", "haven't").Not()
         .Build();
     var q = s.ToString();
     Assert.AreEqual(@"key:foo OR NOT key:bar AND key:[10 TO 20] OR (otherkey:baz AND hash:schmoopy\ for\ president\+*^6 AND (bash:dooby OR NOT dash:fooby) OR bash:smelly) AND NOT (otherkey:baz OR zoom:quux OR zoom:{la TO da}) OR NOT lala:""wouldn\'t haven\'t""~10", q);
 }