public void SimpleIndexFieldUnaryTermSerializesCorrectly() { var s = new RiakFluentSearch("bucket", "field") .Search("foo") .Build(); var q = s.ToString(); Assert.AreEqual("field:foo", 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 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 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 SimpleUnaryTermWithBoostSerializesCorrectly() { var s = new RiakFluentSearch("bucket", "key") .Search("foo") .Boost(5) .Build(); var q = s.ToString(); Assert.AreEqual("key:foo^5", 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 RiakBucketSearchInput Filter(RiakFluentSearch filter) { return Filter(filter.ToString()); }
public RiakBucketSearchInput(RiakFluentSearch query) : this(query.Bucket, query.ToString()) { }
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); }
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); }
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 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); }
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); }