README.md in elasticsearch-model-0.1.4 vs README.md in elasticsearch-model-0.1.5

- old
+ new

@@ -124,11 +124,11 @@ ``` Or configure the client for all models: ```ruby -Elasticsearch::Model.client = Elasticsearch::Client.new log:true +Elasticsearch::Model.client = Elasticsearch::Client.new log: true ``` You might want to do this during you application bootstrap process, e.g. in a Rails initializer. Please refer to the @@ -144,10 +144,13 @@ ```ruby Article.import # => 0 ``` +It's possible to import only records from a specific `scope`, transform the batch with the `transform` +and `preprocess` options, or re-create the index by deleting it and creating it with correct mapping with the `force` option -- look for examples in the method documentation. + No errors were reported during importing, so... let's search the index! ### Searching @@ -505,11 +508,12 @@ ```ruby Article.first.__elasticsearch__.as_indexed_json # => {"id"=>1, "title"=>"Quick brown fox"} ``` -If you want to customize the serialization, just implement the `as_indexed_json` method yourself: +If you want to customize the serialization, just implement the `as_indexed_json` method yourself, +for instance with the [`as_json`](http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html#method-i-as_json) method: ```ruby class Article include Elasticsearch::Model @@ -521,9 +525,12 @@ Article.first.as_indexed_json # => {"title"=>"Quick brown fox"} ``` The re-defined method will be used in the indexing methods, such as `index_document`. + +Please note that in Rails 3, you need to either set `include_root_in_json: false`, or prevent adding +the "root" in the JSON representation with other means. #### Relationships and Associations When you have a more complicated structure/schema, you need to customize the `as_indexed_json` method - or perform the indexing separately, on your own.