当前位置: 首页>>代码示例>>C#>>正文


C# RiakObject.AddIndex方法代码示例

本文整理汇总了C#中RiakObject.AddIndex方法的典型用法代码示例。如果您正苦于以下问题:C# RiakObject.AddIndex方法的具体用法?C# RiakObject.AddIndex怎么用?C# RiakObject.AddIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RiakObject的用法示例。


在下文中一共展示了RiakObject.AddIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IndexesAreSavedWithAnObject

        public void IndexesAreSavedWithAnObject()
        {
            var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");
            o.AddIndex("tacos", "are great!");
            o.AddIndex("age", 12);

            Client.Put(o);

            var result = Client.Get(o.ToRiakObjectId());

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            var ro = result.Value;

            ro.BinIndexes.Count.ShouldEqual(1);
            ro.IntIndexes.Count.ShouldEqual(1);
        }
开发者ID:corkupine,项目名称:CorrugatedIron,代码行数:16,代码来源:RiakIndexTests.cs

示例2: RiakIndexNameManglingIsHandledAutomatically

        public void RiakIndexNameManglingIsHandledAutomatically()
        {
            var riakObject = new RiakObject(Bucket, Key, "value");
            riakObject.AddIndex("name", "jeremiah");
            riakObject.AddIndex("state_bin", "oregon");
            riakObject.AddIndex("age", 32);
            riakObject.AddIndex("cats_int", 2);

            riakObject.Indexes.Keys.Contains("name").ShouldBeFalse();
            riakObject.Indexes.Keys.Contains("age").ShouldBeFalse();
            riakObject.Indexes.Keys.Contains("state").ShouldBeFalse();
            riakObject.Indexes.Keys.Contains("state_bin_bin").ShouldBeFalse();
            riakObject.Indexes.Keys.Contains("cats").ShouldBeFalse();
            riakObject.Indexes.Keys.Contains("cats_int_int").ShouldBeFalse();

            riakObject.Indexes.Keys.Contains("name_bin").ShouldBeTrue();
            riakObject.Indexes.Keys.Contains("age_int").ShouldBeTrue();
            riakObject.Indexes.Keys.Contains("state_bin").ShouldBeTrue();
            riakObject.Indexes.Keys.Contains("cats_int").ShouldBeTrue();
        }
开发者ID:corkupine,项目名称:CorrugatedIron,代码行数:20,代码来源:RiakObjectTests.cs

示例3: BinIndexGetReturnsListOfKeys

        public void BinIndexGetReturnsListOfKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, i.ToString(), "{ value: \"this is an object\" }");
                o.AddIndex("age", "32");

                Client.Put(o);
            }

            var result = Client.IndexGet(Bucket, "age", "32");
            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            result.Value.Count.ShouldEqual(10);

            foreach (var v in result.Value)
            {
                var key = int.Parse(v);
                key.ShouldBeLessThan(10);
                key.ShouldBeGreaterThan(-1);
            }
        }
开发者ID:corkupine,项目名称:CorrugatedIron,代码行数:21,代码来源:RiakIndexTests.cs

示例4: QueryingByIntIndexReturnsAListOfKeys

        public void QueryingByIntIndexReturnsAListOfKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, i.ToString(), "{\"value\":\"this is an object\"}");
                o.AddIndex("age", 32);

                Client.Put(o);
            }

            var mr = new RiakMapReduceQuery()
                .Inputs(RiakIndex.Match(Bucket, "age", 32));

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

            var keys = result.Value.PhaseResults.SelectMany(x => x.GetObjects<RiakObjectId>()).ToList();

            keys.Count().ShouldEqual(10);

            foreach (var key in keys)
            {
                key.Bucket.ShouldNotBeNullOrEmpty();
                key.Key.ShouldNotBeNullOrEmpty();
            }
        }
开发者ID:corkupine,项目名称:CorrugatedIron,代码行数:26,代码来源:RiakIndexTests.cs

示例5: IntRangeQueriesReturnMultipleKeys

        public void IntRangeQueriesReturnMultipleKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, i.ToString(), "{ value: \"this is an object\" }");
                o.AddIndex("age", 25 + i);

                Client.Put(o);
            }

            var mr = new RiakMapReduceQuery()
                .Inputs(RiakIndex.Range(Bucket, "age", 27, 30))
                .ReduceErlang(r => r.ModFun("riak_kv_mapreduce", "reduce_identity").Keep(true));

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

            // TODO write tests verifying results
        }
开发者ID:corkupine,项目名称:CorrugatedIron,代码行数:19,代码来源:RiakIndexTests.cs


注:本文中的RiakObject.AddIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。