public void Init()
        {
            SetUp();

            var index = new SearchIndex(Index);
            Client.PutSearchIndex(index);

            Func<RiakResult<RiakBucketProperties>, bool> indexIsSet =
                result => result.IsSuccess &&
                          result.Value != null &&
                          !string.IsNullOrEmpty(result.Value.SearchIndex);

            Func<RiakResult<RiakBucketProperties>> setBucketProperties =
                () =>
                {
                    RiakBucketProperties props = Client.GetBucketProperties(BucketType, Bucket).Value;
                    props.SetSearchIndex(Index);
                    Client.SetBucketProperties(BucketType, Bucket, props);
                    return Client.GetBucketProperties(BucketType, Bucket);
                };

            setBucketProperties.WaitUntil(indexIsSet);
            System.Threading.Thread.Sleep(5000); // Wait for Yoko to start up
            PrepSearch();
        }
        public void SetUpFixture()
        {
            base.CreateClient();

            var getIndexResult = client.GetSearchIndex("scores");
            if (!getIndexResult.IsSuccess)
            {
                var searchIndex = new SearchIndex("scores", "_yz_default");
                CheckResult(client.PutSearchIndex(searchIndex));
            }

            getIndexResult = client.GetSearchIndex("hobbies");
            if (!getIndexResult.IsSuccess)
            {
                var searchIndex = new SearchIndex("hobbies", "_yz_default");
                CheckResult(client.PutSearchIndex(searchIndex));
            }

            getIndexResult = client.GetSearchIndex("customers");
            if (!getIndexResult.IsSuccess)
            {
                var searchIndex = new SearchIndex("customers", "_yz_default");
                CheckResult(client.PutSearchIndex(searchIndex));
            }
        }
        public void TestStoreAndFetchIndex()
        {
            var indexName = "index" + Random.Next();
            var index = new SearchIndex(indexName, RiakConstants.Defaults.YokozunaIndex.DefaultSchemaName, (NVal)2);

            var putIndexResult = Client.PutSearchIndex(index);

            Assert.True(putIndexResult.IsSuccess, "Index Not Created: {0}", putIndexResult.ErrorMessage);
            Func<RiakResult<SearchIndexResult>> func = () => Client.GetSearchIndex(indexName);
            var getIndexResult = func.WaitUntil();

            Assert.True(getIndexResult.IsSuccess, "Index Not Fetched: {0}", getIndexResult.ErrorMessage);
            Assert.AreEqual(1, getIndexResult.Value.Indexes.Count);
            var fetchedIndex = getIndexResult.Value.Indexes.First();
            Assert.AreEqual(indexName, fetchedIndex.Name);
            Assert.AreEqual(2, fetchedIndex.NVal);
        }
Exemplo n.º 4
0
        public void SetUpFixture()
        {
            if (!File.Exists(blogPostSchemaFileName))
            {
                Console.WriteLine("Writing {0} in {1}", blogPostSchemaFileName, Environment.CurrentDirectory);
                var req = WebRequest.Create(blogPostSchema);
                var rsp = req.GetResponse();
                var stream = rsp.GetResponseStream();
                string line = string.Empty;
                using (var writer = new StreamWriter(blogPostSchemaFileName))
                {
                    using (var rdr = new StreamReader(stream))
                    {
                        while ((line = rdr.ReadLine()) != null)
                        {
                            writer.WriteLine(line);
                        }
                    }
                }
            }

            base.CreateClient();

            var getSchemaResult = client.GetSearchSchema("blog_post_schema");
            if (!getSchemaResult.IsSuccess)
            {
                var schemaXml = File.ReadAllText(blogPostSchemaFileName);
                var schema = new SearchSchema(blogPostSchemaName, schemaXml);
                var rslt = client.PutSearchSchema(schema);
                CheckResult(rslt);

                WaitForSearch();

                var idx = new SearchIndex("blog_posts", "blog_post_schema");
                rslt = client.PutSearchIndex(idx);
                CheckResult(rslt);
            }
        }
        private void SetupSearchIndexes()
        {
            var index = new SearchIndex(Index);
            index.Timeout = TimeSpan.FromSeconds(60);
            RiakResult rrslt = Client.PutSearchIndex(index);
            Assert.True(rrslt.IsSuccess, rrslt.ErrorMessage);

            RiakBucketProperties props = null;

            Func<RiakResult<RiakBucketProperties>, bool> propsExist =
                result => result != null && result.Value != null && props != null;

            Func<RiakResult<RiakBucketProperties>, bool> indexIsSet =
                result => result != null &&
                          result.IsSuccess &&
                          result.Value != null &&
                          !string.IsNullOrEmpty(result.Value.SearchIndex);

            Func<RiakResult<RiakBucketProperties>> getBucketProperties = () =>
                {
                    RiakResult<RiakBucketProperties> rslt = Client.GetBucketProperties(BucketType, Bucket);
                    if (rslt.Value != null)
                    {
                        props = rslt.Value;
                    }
                    return rslt;
                };

            getBucketProperties.WaitUntil(propsExist);

            props.SetSearchIndex(Index);
            rrslt = Client.SetBucketProperties(BucketType, Bucket, props);
            Assert.True(rrslt.IsSuccess, rrslt.ErrorMessage);

            getBucketProperties.WaitUntil(indexIsSet);
            Thread.Sleep(5000); // Wait for Yoko to start up
        }
Exemplo n.º 6
0
 public void CreateSearchIndexWithDefaultSchema()
 {
     var idx = new SearchIndex("famous", "_yz_default");
     var rslt = client.PutSearchIndex(idx);
     CheckResult(rslt);
 }
Exemplo n.º 7
0
 public void CreateSearchIndex()
 {
     var idx = new SearchIndex("famous");
     var rslt = client.PutSearchIndex(idx);
     CheckResult(rslt);
 }
        public void TestDeleteIndex()
        {
            var indexName = "index" + Random.Next();
            var index = new SearchIndex(indexName);
            var putIndexResult = Client.PutSearchIndex(index);
            Assert.True(putIndexResult.IsSuccess, "Index Not Created: {0}", putIndexResult.ErrorMessage);

            // Wait until index can be fetched, or else you can run into a race condition where the index is not found on another node. 
            Func<RiakResult<SearchIndexResult>> fetchIndex = () => Client.GetSearchIndex(indexName);
            var fetchIndexResult = fetchIndex.WaitUntil();
            Assert.True(fetchIndexResult.IsSuccess, "Index Not Found After Creation: {0}", fetchIndexResult.ErrorMessage);

            Func<RiakResult> deleteIndex = () => Client.DeleteSearchIndex(indexName);
            var deleteIndexResult = deleteIndex.WaitUntil();

            Assert.True(deleteIndexResult.IsSuccess, "Index Not Deleted: {0}", deleteIndexResult.ErrorMessage);

        }