var clientConfiguration = GetConfiguration("couchbase.json");
ClusterHelper.Initialize(clientConfiguration);
var bucket = ClusterHelper.GetBucket("flamebucket");
var bucketManager= bucket.CreateManager();
bucketManager.CreateN1qlPrimaryIndex(false);
bucket.Upsert("google:one", new Blog { Id = 1, BlogName = "i 1th blog" });
bucket.Upsert("google:two", new Blog { Id = 2, BlogName = "i 2th blog" });
bucket.Upsert("flame:three", new Blog { Id = 3, BlogName = "i 3th blog" });
bucket.Upsert("ro:four", new Blog { Id = 4, BlogName = "i 4th blog" });
bucket.Upsert("ro:five", new Blog { Id = 5, BlogName = "i 5th blog" });
while (true)
{
Console.Clear();
Console.WriteLine("please input google flame ro");
string keyprefix = Console.ReadLine();
if (keyprefix.StartsWith("q"))
{
break;
}
var query = bucket.CreateQuery("flamedesigndoc", "allkeys", false).StartKey(keyprefix).EndKey(keyprefix+ "\ufff0");
var result = bucket.Query<Blog>(query);
foreach (var row in result.Rows)
{
Console.WriteLine(" key: "+row.Key);
Console.WriteLine("=====id:"+row.Value.Id +" blogName: "+ row.Value.BlogName);
}
Console.ReadLine();
}
Console.Read();