File tree 1 file changed +33
-12
lines changed
elasticsearch-model/lib/elasticsearch/model
1 file changed +33
-12
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,29 @@ module ClassMethods
53
53
#
54
54
# @yield [Hash] Gives the Hash with the Elasticsearch response to the block
55
55
#
56
- # @return [Fixnum] Number of errors encountered during importing
56
+ # @return [Fixnum] default, number of errors encountered during importing
57
+ # @return [Array<Hash>] if +return+ option is specified to be +"errors"+,
58
+ # contains only those failed items in the response +items+ key, e.g.:
59
+ #
60
+ # [
61
+ # {
62
+ # "index" => {
63
+ # "error" => 'FAILED',
64
+ # "_index" => "test",
65
+ # "_type" => "_doc",
66
+ # "_id" => '1',
67
+ # "_version" => 1,
68
+ # "result" => "foo",
69
+ # "_shards" => {
70
+ # "total" => 1,
71
+ # "successful" => 0,
72
+ # "failed" => 1
73
+ # },
74
+ # "status" => 400
75
+ # }
76
+ # }
77
+ # ]
78
+ #
57
79
#
58
80
# @example Import all records into the index
59
81
#
@@ -99,20 +121,19 @@ module ClassMethods
99
121
#
100
122
# @example Update the batch before yielding it
101
123
#
102
- # class Article
103
- # # ...
104
- # def self.enrich(batch)
105
- # batch.each do |item|
106
- # item.metadata = MyAPI.get_metadata(item.id)
107
- # end
108
- # batch
109
- # end
110
- # end
124
+ # class Article
125
+ # # ...
126
+ # def self.enrich(batch)
127
+ # batch.each do |item|
128
+ # item.metadata = MyAPI.get_metadata(item.id)
129
+ # end
130
+ # batch
131
+ # end
132
+ # end
111
133
#
112
134
# Article.import preprocess: :enrich
113
135
#
114
- # @example Return an array of error elements instead of the number of errors, eg.
115
- # to try importing these records again
136
+ # @example Return an array of error elements instead of the number of errors, e.g. to try importing these records again
116
137
#
117
138
# Article.import return: 'errors'
118
139
#
You can’t perform that action at this time.
0 commit comments