我正在阅读Rob Ashton在Ravendb上的出色博客文章:http://codeofrob.com/archive/2010/05/09/ravendb-an-introduction.aspx

而且我在阅读时要处理代码。但是,当我尝试添加索引时,我会收到401错误。这是代码:

class Program
{
    static void Main(string[] args)
    {
        using (var documentStore = new DocumentStore() { Url = "http://localhost:8080" })
        {

            documentStore.Initialise();

            documentStore.DatabaseCommands.PutIndex(
                "BasicEntityBySomeData",
                new IndexDefinition<BasicEntity, BasicEntity>()
                {
                    Map = docs => from doc in docs
                                  where doc.SomeData != null
                                  select new
                                  {
                                      SomeData = doc.SomeData
                                  },
                });


            string entityId;

            using (var documentSession = documentStore.OpenSession())
            {
                var entity = new BasicEntity()
                {
                    SomeData = "Hello, World!",
                    SomeOtherData = "This is just another property",
                };

                documentSession.Store(entity);
                documentSession.SaveChanges();

                entityId = entity.Id;

                var loadedEntity = documentSession.Load<BasicEntity>(entityId);
                Console.WriteLine(loadedEntity.SomeData);

                var docs = documentSession.Query<BasicEntity>("BasicEntityBySomeData")
                    .Where("SomeData:Hello~")
                    .WaitForNonStaleResults()
                    .ToArray();

                docs.ToList().ForEach(doc => Console.WriteLine(doc.SomeData));

                Console.Read();
            }

        }
    }

当在线路上拨打putindex()调用时,它会丢弃401错误。有什么想法我需要适用什么权限?我需要在哪里应用它们?

有帮助吗?

解决方案

服务器模式是什么意思?您是说简单地执行Raven.Server吗?

尽管我不得不经营乌鸦,但我不必做任何特殊的客户端才能使其正常工作。 (实际上,我将在邮件列表上提出有关该问题的查询)

除非您更改了Raven.Server的配置,否则您不应遇到401错误。

如果您正在运行服务器,则可以使用配置中指定的URL直接浏览(Localhost:8080)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top