https://github.com/rs/rest-layer-es
REST Layer ElasticSearch resource storage handler
https://github.com/rs/rest-layer-es
Last synced: 11 months ago
JSON representation
REST Layer ElasticSearch resource storage handler
- Host: GitHub
- URL: https://github.com/rs/rest-layer-es
- Owner: rs
- Created: 2016-02-24T09:16:56.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-11-27T14:15:09.000Z (over 7 years ago)
- Last Synced: 2025-04-15T14:13:30.259Z (about 1 year ago)
- Language: Go
- Size: 22.5 KB
- Stars: 5
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# REST Layer ElasticSearch Backend
[](https://godoc.org/github.com/rs/rest-layer-es) [](https://raw.githubusercontent.com/rs/rest-layer-es/master/LICENSE) [](https://travis-ci.org/rs/rest-layer-es)
This [REST Layer](https://github.com/rs/rest-layer) resource storage backend stores data in an ElasticSearch cluster using [olivere/elastic](http://gopkg.in/olivere/elastic.v3).
ElasticSearch v5+ is required.
## Usage
```go
import "github.com/rs/rest-layer-es"
```
Create an [elastic]("http://gopkg.in/olivere/elastic.v5") client:
```go
client, err := elastic.NewClient()
```
Create a resource storage handler with a given DB/collection:
```go
s := es.NewHandler(client, "index", "type")
```
Use this handler with a resource:
```go
index.Bind("foo", foo, s, resource.DefaultConf)
```
You may want to create as many ElasticSearch handlers with different index and/or type. You can share the same `elastic` client across all you handlers.