public void SettingLegacySearchOnRiakBucketMakesBucketSearchable()
        {
            var bucket = Guid.NewGuid().ToString();
            var key = Guid.NewGuid().ToString();
            var props = Client.GetBucketProperties(bucket).Value;
            props.SetLegacySearch(true);

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

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

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

            var search = new RiakSearchRequest
            {
                Query = q
            };

            var searchResult = Client.Search(search);
            searchResult.IsSuccess.ShouldBeTrue(searchResult.ErrorMessage);
            searchResult.Value.NumFound.ShouldEqual(1u);
            searchResult.Value.Documents[0].Fields.Count.ShouldEqual(3);
            searchResult.Value.Documents[0].Fields.First(x => x.Key == "id").Value.ShouldEqual(key);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RiakSearchRequest"/> class.
        /// </summary>
        /// <param name="solrQuery">The Solr query as expressed by an instance of <see cref="RiakFluentSearch"/>.</param>
        /// <param name="solrFilter">The Solr filter as expressed by an instance of <see cref="RiakFluentSearch"/>. Defaults to <c>null</c>.</param>
        /// <exception cref="ArgumentException"><paramref name="solrIndex"/> cannot be null, zero length, or whitespace</exception>
        /// <exception cref="ArgumentException"><paramref name="solrQuery"/> cannot be null, zero length, or whitespace</exception>
        public RiakSearchRequest(
            RiakFluentSearch solrQuery,
            RiakFluentSearch solrFilter = null)
        {
            if (solrQuery == null)
            {
                throw new ArgumentNullException("solrQuery");
            }

            this.Query  = solrQuery;
            this.Filter = solrFilter;
        }
        public void UsingFluentQueryProducesSameQueryAsString()
        {
            string index = "index";
            string field = "data_s";
            string search = "frazzle";
            string solrQuery = string.Format("{0}:{1}", field, search);

            var fluentSearch = new RiakFluentSearch(index, field).Search(search).Build();
            var s1 = new RiakSearchRequest { Query = fluentSearch };
            var s2 = new RiakSearchRequest(index, solrQuery);

            Assert.AreEqual(s1, s2);
        }
        public void UsingFluentQueryWithFilterProducesSameQueryAsString()
        {
            string index = "index";
            string field = "data_s";
            string search = "frazzle";
            string solrQuery = string.Format("{0}:{1}", field, search);
            string solrFilter = string.Format("{0}:[10 TO 20]", field);

            var fluentSearch = new RiakFluentSearch(index, field).Search(search).Build();
            var fluentFilter = new RiakFluentSearch(index, field).Between("10", "20", true).Build();
            var s1 = new RiakSearchRequest { Query = fluentSearch, Filter = fluentFilter };
            var s2 = new RiakSearchRequest(index, solrQuery, solrFilter);

            Assert.AreEqual(s1, s2);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProximityTerm"/> class.
 /// </summary>
 /// <param name="search">The fluent search to add this term to.</param>
 /// <param name="field">The field to search.</param>
 /// <param name="proximity">The maximum distance the words can be from each other.</param>
 /// <param name="words">The set of words to find within a certain distance of each other.</param>
 internal ProximityTerm(RiakFluentSearch search, string field, double proximity, params string[] words)
     : base(search, field)
 {
     this.words     = new List <Token>(words.Select(Token.Is));
     this.proximity = proximity;
 }
Beispiel #6
0
 protected Term(RiakFluentSearch search, string field)
 {
     this.search = search;
     this.field  = field;
 }
        public void SearchingComplexQueryWorks()
        {
            var search = new RiakFluentSearch(Index, "name_s");

            // name_s:{integer}Al* AND bio_tsd:awesome AND bio_tsd:an AND (bio_tsd:mathematician OR favorites.album_tsd:Fame)
            search.Search(Token.StartsWith(_randomId + "Al"))
                .And("bio_tsd", "awesome")
                .And("an")
                .And("mathematician", s => s.Or("favorites.album_tsd", "Fame"));

            var mr = new RiakMapReduceQuery().Inputs(new RiakSearchInput(search));

            var result = Client.RunMapReduceQuery(mr).WaitUntil(MapReduceTestHelpers.OnePhaseWithOneResultFound);

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            var singleResult = result.Value.PhaseResults.First().Values[0].FromRiakString();
            var failureMessage = string.Format("Results did not contain \"{0}\". \r\nResult was:\"{1}\"",
                PublicKey, singleResult);
            singleResult.Contains(PublicKey).ShouldBeTrue(failureMessage);
        }
        public void SearchingViaFluentSearchObjectWorks()
        {
            var search = new RiakFluentSearch(Index, "name_s").Search(Token.StartsWith(_randomId + "Al")).Build();
            var mr = new RiakMapReduceQuery().Inputs(new RiakSearchInput(search));

            var result = Client.RunMapReduceQuery(mr).WaitUntil(MapReduceTestHelpers.OnePhaseWithTwoResultsFound);

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);

            AssertThatResultContainsAllKeys(result);
        }
        public void SearchingViaFluentSearchObjectWorks()
        {
            var search = new RiakFluentSearch(Bucket, "name").Search(Token.StartsWith("Al")).Build();
#pragma warning disable 612, 618
            var mr = new RiakMapReduceQuery().Inputs(new RiakBucketSearchInput(search));
#pragma warning restore 612, 618

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

            CheckThatResultContainAllKeys(result);
        }
 protected Term(RiakFluentSearch search, string field)
 {
     this.search = search;
     this.field = field;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProximityTerm"/> class.
 /// </summary>
 /// <param name="search">The fluent search to add this term to.</param>
 /// <param name="field">The field to search.</param>
 /// <param name="proximity">The maximum distance the words can be from each other.</param>
 /// <param name="words">The set of words to find within a certain distance of each other.</param>
 internal ProximityTerm(RiakFluentSearch search, string field, double proximity, params string[] words)
     : base(search, field)
 {
     this.words = new List<Token>(words.Select(Token.Is));
     this.proximity = proximity;
 }