user1765862 user1765862 - 27 days ago 20
C# Question

Querying data in ravendb

Inside ravendb I have Properties documents. Each document has besides other properties UniqueCode. How can I query document for specific document inside ravendb management studio.

I tried inside Query (top level link) using

from d in docs.Properties
where d.UniqueCode == 1234
select d;


But I'm getting
No results found


Metadata for each property document is

{
"Raven-Entity-Name": "Properties",
"Raven-Clr-Type": "MyProject.Test.Data.Domain.Model.Property, MyProject.Test.Data"
}

Answer

The query UI in RavenDb Management Studio uses Lucene syntax, and operates on indexes.

You need to first define an index that includes any fields you want to be able to search on:

from p in docs.Properties
select new {
    p.UniqueCode
}

Now you can use lucene syntax to actually query this:

UniqueCode: 1234

Using the RavenDb sample, I will define a similar query:

ProductReorderLevel query

and then can find all products matching a specific value:

enter image description here

Comments