4

I have no problem querying RavenDB from code, but sometimes a quick lookup directly to RavenDB would be nice. Unfortunately, I cannot figure it out despite tips that it uses Lucene syntax.

For example, I have a RegionLocation document:

{
  "RegionId": 804291854,
  "Name": "Miami",
  "Description": null,
  "DbRowStatus": 0,
  "CreatedBy": "Zorro",
  "UpdatedBy": null,
  "DeletedBy": null,
  "CreatedOn": "2013-06-05T18:31:37.4332753",
}

I haven't had any luck with quering it. RegionLocation.Name: M* returns no results. Any idea what I am doing wrong?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
Zulu Z
  • 1,103
  • 5
  • 14
  • 27

1 Answers1

7

Assuming you already have an index that has the name mapped, or you are building a new dynamic index against the RegionLocation documents, then the syntax for your query would just be:

Name: M*

I agree that the documentation could be better - especially the in-application help. But you can find most of what you need to know here.

UPDATE

This was raised as Issue #1250, and closed in RavenDB 2.5.2750. The studio now includes easily accessible help:

                  Screenshot

The popup shows when you hover over the (i) icon, and the "Query syntax online" link points at the relevant Lucene documentation.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • thanks, it works without Document name, weird because when I change Index source from the menu it is automatically added to .Name...BTW why it has to be index there? In SQL server I can query all fields whether are indexed or not. – Zulu Z Aug 01 '13 at 20:17
  • 1
    Matt I have to disagree, I mean your solution works but the documentation lacks and lacks a lot. There is not explanation of what kind of Syntax studio is able to accept and the intellisense give you the wrong "impression" when building a query. Far away from being a complete product IMHO – Raffaeu Apr 23 '14 at 11:15
  • @Raffaeu - Not sure why you think this one bit of contextual help would make or break it being a "complete product", but as you can see by my updated answer - this was already addressed last October. – Matt Johnson-Pint Apr 23 '14 at 16:48
  • 1
    @MattJohnson it does in the moment that the product is not using a standard query language like T-SQL or LinQ and it forces you to "guess" the syntax. Look at LinqPad, that's a complete query editor – Raffaeu Apr 25 '14 at 10:41
  • @Raffaeu - It uses Lucene syntax. You might not be as familiar with that as TSQL or LINQ, but that's because it serves a different purpose. It *does* provide Intellisense, if that's what you're looking for. If you think it should be something more, perhaps consider contributing to the [new HTML-based studio for Raven3](https://github.com/JudahGabriel/ravendb/tree/Raven.Studio.Html5/Raven.Studio.Html5). But this is getting off topic for StackOverflow... – Matt Johnson-Pint Apr 25 '14 at 16:14
  • @MattJohnson I was able to speak with Ayende and get a clear explanation of what is RavenDB and how it is supposed to be used. For ETL and Reporting I have been suggested to replicate the data over SQL Server and build my Cubes/Reports using a RDBMS instead of RavenDB. – Raffaeu Apr 28 '14 at 08:28