wj-mongoid-elasticsearch 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/elasticsearch/response.rb +41 -3
- data/lib/mongoid/elasticsearch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efc3e33f5abe8cb10787af60e2a9d8dbdb90154e
|
4
|
+
data.tar.gz: d3dd2b90f47f9350a00cc84afc50c6c045ed7afe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97e5e116bf33cd9c1bd868d6f0c56a41e161b0f28d00d96b73431f9be3ca4cadecb95f5de306ab0feb2be38659882a5cc19065e9657ec42b85f9bfe756242a15
|
7
|
+
data.tar.gz: b4c74b6c8b07e1cbe8390eeed2848ab9cdb4e794e90519d8cc29cd67eb420e66168c628cfd2bd7e31c50c57413ee8031b5dff052abdf2c7ef790ae5b0bc688c2
|
@@ -50,6 +50,8 @@ module Mongoid
|
|
50
50
|
def results
|
51
51
|
return [] if failure?
|
52
52
|
@results ||= begin
|
53
|
+
puts "here are the hits."
|
54
|
+
puts JSON.pretty_generate(hits)
|
53
55
|
case @wrapper
|
54
56
|
when :load
|
55
57
|
if @multi
|
@@ -63,24 +65,32 @@ module Mongoid
|
|
63
65
|
end
|
64
66
|
end
|
65
67
|
when :mash
|
68
|
+
|
66
69
|
hits.map do |h|
|
67
70
|
s = h.delete('_source')
|
68
71
|
m = Hashie::Mash.new(h.merge(s))
|
69
72
|
if defined?(Moped::BSON)
|
70
73
|
m.id = Moped::BSON::ObjectId.from_string(h['_id'])
|
71
74
|
else
|
75
|
+
|
72
76
|
m.id = BSON::ObjectId.from_string(h['_id'])
|
73
77
|
end
|
74
78
|
m._id = m.id
|
75
79
|
m
|
76
80
|
end
|
77
81
|
when :model
|
82
|
+
|
78
83
|
multi_without_load
|
79
84
|
else
|
80
85
|
hits
|
81
86
|
end
|
82
87
|
|
83
88
|
end
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
84
94
|
end
|
85
95
|
|
86
96
|
def error
|
@@ -142,13 +152,41 @@ module Mongoid
|
|
142
152
|
records = {}
|
143
153
|
hits.group_by { |item| item['_type'] }.each do |type, items|
|
144
154
|
klass = find_klass(type)
|
145
|
-
|
155
|
+
####################################################
|
156
|
+
##
|
157
|
+
##
|
158
|
+
## THIS LINE REMOVED AND SUBSEQUENT BLOCK ADDED.
|
159
|
+
##
|
160
|
+
##
|
161
|
+
####################################################
|
162
|
+
#records[type] = klass.find(items.map { |h| h['_id'] })
|
163
|
+
|
164
|
+
####################################################
|
165
|
+
##
|
166
|
+
##
|
167
|
+
##
|
168
|
+
## WHOLE SUBSEQUENT BLOCK IS ADDED.
|
169
|
+
##
|
170
|
+
##
|
171
|
+
####################################################
|
172
|
+
items.each do |h|
|
173
|
+
begin
|
174
|
+
records[type]||= []
|
175
|
+
records[type] << klass.find(h['_id'])
|
176
|
+
rescue => e
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
146
181
|
end
|
147
182
|
|
148
183
|
# Reorder records to preserve the order from search results
|
149
184
|
hits.map do |item|
|
150
|
-
|
151
|
-
|
185
|
+
### THIS LINE WAS ADDED TO CHECK IF THE TYPE EXISTS.
|
186
|
+
if records[item['_type']]
|
187
|
+
records[item['_type']].detect do |record|
|
188
|
+
record.id.to_s == item['_id'].to_s
|
189
|
+
end
|
152
190
|
end
|
153
191
|
end
|
154
192
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wj-mongoid-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|