Skip to content

Commit d29f270

Browse files
committed
[STORE] Added information about setting up a client for Model::Persistence to the README
Closes elastic#246
1 parent 51cbe7b commit d29f270

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

elasticsearch-persistence/README.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,32 @@ puts results.response.aggregations.authors.buckets.each { |b| puts "#{b['key']}
602602
# John : 1
603603
```
604604

605-
#### Accessing the Repository Gateway
605+
#### The Elasticsearch Client
606+
607+
The module will set up a [client](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch),
608+
connected to `localhost:9200`, by default.
609+
610+
To use a client with different configuration:
611+
612+
```ruby
613+
Elasticsearch::Persistence.client = Elasticsearch::Client.new log: true
614+
```
615+
616+
To set up a specific client for a specific model:
617+
618+
```ruby
619+
Article.client = Elasticsearch::Client.new host: 'api.server.org'
620+
```
621+
622+
You might want to do this during you application bootstrap process, e.g. in a Rails initializer.
623+
624+
Please refer to the
625+
[`elasticsearch-transport`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport)
626+
library documentation for all the configuration options, and to the
627+
[`elasticsearch-api`](http://rubydoc.info/gems/elasticsearch-api) library documentation
628+
for information about the Ruby client API.
629+
630+
#### Accessing the Repository Gateway and the Client
606631

607632
The integration with Elasticsearch is implemented by embedding the repository object in the model.
608633
You can access it through the `gateway` method:

0 commit comments

Comments
 (0)