RavenDB 3.0 Survival Guide


Search for foo and not bar in title:

title:foo -title:bar

Nested properties

	User: {
		Name: "Brian"

Use the following query to match:

User.Name: Brian


	"Tags" : [
			"Name" : "sport"
			"Name" : "tv"

Use the following query to match:

Tags,Name: sport

Numeric values

Age: 20                     # match exact
Age_Range: {20 TO NULL}     # append _Range to match 20+

Multiple words

<<word1 word2>>             # or
(word1 word2)


@in: (Brian, Charlotte)              # look for names containing Brian or Charlotte. Comma is the separator
@in:("Australia`,`Canada", Israel)   # match Australia,Canada OR Israel.  Use grave accent ` to escape the comma

null or ""

In order to get users that have a null or empty name specify the query:


Not null

*:* AND NOT Email:[[NULL_VALUE]]

Not in list

*:* AND -CustomerId: (1 2 3)

Query dates

To query a date (from beginning to 2014/04/20):

EndDate: [NULL TO 2014-04-20T23:59:59.9999999]

In case of failure

To repair database:

cd RavenDBDatabases{database_name}
rem Adds information in logs to database - do this first
esentutl /r RVN /l logs /s system

rem Recover data - may loose information (this is a lengthy process)
esentutl /p Data

rem Defragment database (this is a lengthy process)
esentutl /d Data

... do for all corrupted databases.

See also https://support.microsoft.com/en-us/kb/314917.

Import (defect) database

Original thread: https://groups.google.com/forum/#!searchin/ravendb/bummer%7Csort:relevance/ravendb/gOHL1SjzqUg/3-7XjxVhCQAJ.

See if documents are deleted:

  1. Create an empty temporary database without versioning -< let's call it TempDB.
  2. Export your original database.
  3. Import the new exported file to TempDB.
  4. In TempDB, create an index that will contain all of the documents with a field called Raven-Document-Revision-Status in the metadata:
    from doc in docs
    select new
    	Revision = doc["@metadata"]["Raven-Document-Revision-Status"]
  5. Now query TempDB by the index for all the document where Revision = "Historical". This will get you only the docs with revisions.
  6. Get the prefix for each doc and query the original database (to see if the original exists there), if it doesn't exist create it from the revision doc you have (the latest off course).

Export only documents

raven.smuggler out http://localhost:8080 c:\\users\\bschau\\desktop\\database.dmp --database=... --operate-on-types=Documents --metadata-filter=Raven-Document-Revision-Status=Current

Rename collection

Run the following patch on the collection to rename:

this['@metadata']['Raven-Entity-Name'] = "new-name-of-collection-remember-to-pluralize";