Derek Ekins
Derek Ekins

Reputation: 11391

How do you use ravendb facets with the http api?

I am using the http api (no .net) to use raven.

I can't find any documentation regarding using facets directly using the http api.

If you have done this before then please answer with a brief overview of urls and json required to setup and query a facet.

Thanks

Upvotes: 1

Views: 148

Answers (1)

Derek Ekins
Derek Ekins

Reputation: 11391

Turns out this is fairly simple.

First of all define the facet, to do this simply save the facet as a document in the database with the id facets/[your-facet-name]

A facet document looks like this:

{
  "Facets": [
    {
      "Mode": "Default",
      "Name": "type",
      "Ranges": []
    }
  ]
}

You can read more about the options for the Facet object here

Now assuming you have already setup an index called my-index you can use the facet by getting the url:

/databases/[your-database-name]/facets/[your-index-name]/facetDoc=facets/[your-facet-name]&query=[your-query]

The query is the normal lucene query format you would use when querying an index.

As it happens most of this information is already on the facets page you just have to read it closely!

Upvotes: 2

Related Questions