English 中文(简体)
What permissions do I need to grant to run RavenDB in Server mode?
原标题:
  • 时间:2010-05-13 19:22:26
  •  标签:
  • ravendb

I m reading through Rob Ashton s excellent blog post on RavenDB: http://codeofrob.com/archive/2010/05/09/ravendb-an-introduction.aspx

and I m working through the code as I read. But when I try to add an index, I get a 401 error. Here s the code:

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();
            }

        }
    }

It throws the 401 error when on the line that makes the PutIndex() call. Any ideas what permissions I need to apply? And where I need to apply them?

最佳回答

What do you mean by Server mode? Do you mean simply executing Raven.Server?

I ve not had to do anything special client-side to get that to work, although I have had to run Raven.Server with elevated privileges because I m not sure the code to ask for relevant permissions is quite working as intended. (Actually, I ll raise a query about that on the mailing list)

You shouldn t be getting a 401 error unless you ve changed the configuration of Raven.Server.

If you re running the server, you can browse to it directly using the url specified in configuration (localhost:8080 by default) - make sure it s actually running and working as intended before continuing with troubleshooting

问题回答

暂无回答




相关问题
RavenDB: Grammatical and phonetical analysis?

I m a little confused about the level of integration between Lucene.NET and RavenDB. Lucene supports grammatical and phonetical analysis of texts (like word stemming, Metaphone) to allow searches ...

RavenDB: Id Generation For Sub-Documents

I m trying migrating an existing web application to use RavenDB. I currently have pages in my web application which allow you to view Categories, SubCategories and Resources based on an id in the ...

Updating documents in RavenDB

If you add, delete or rename a property on a persisted entity, what s the easiest way to update the documents in RavenDB?

Lucene Boolean Query on Not ANalyzed Fields

Using RavenDB to do a query on Lucene Index. This query parses okay: X:[[a]] AND Y:[[b]] AND Z:[[c]] However this query gives me a parse exception: X:[[a]] AND Y:[[b]] AND Z:[[c]] AND P:[[d]] "...

.Net Finalizer Order / Semantics in Esent and Ravendb

Help me understand. I ve read that "The time and order of execution of finalizers cannot be predicted or pre-determined" Correct? However looking at RavenDB source code TransactionStorage.cs I see ...

热门标签