ravendbravendb-http

How to query RavenDB using HTTP API for all documents of a type


I'm trying to query RavenDB using the HTTP client for all documents by type. I would like a collection of the documents with a given type.

I understand that there might be limitations only the first 1024 documents will be returned. I am well under that number and besides it's for a proof of concept.

I am able to obtain all the documents using the following syntax:

         http://localhost:8080/databases/{database name}/docs/

I see that I could use the @metadata field to get the documents of the type I want but I don't know the syntax.

Since the HTTP api allows you to query indexes, I attempted to write a static index. When I wrote the index from Raven Studio, the index was not returning the documents of the type I wanted. It was giving zero results.

         from doc in docs.MyType
         select new { doc};

I also tried this:

         from doc in docs 
         let Tag = doc["@metadata"]["Raven-Entity-Name"] 
         where Tag == "MyType"
         select new { doc};

Solution

  • You can do it using:

              http://localhost:8080/databases/{database name}/indexes/dynamic/CollectionName