wj-mongoid-elasticsearch 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed51025a8797c0ead1ce01e9bce500f465aeed22
|
4
|
+
data.tar.gz: 3e40c6978d0d607a0f6a0335a1389447285c7a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6645b0ca4a9b00c7d390e4dfa8851bf6b547be099b14ec739d3b57d2650219bd907e8aa99c6c3d038a1120fc8dcdac9115f20322cc9457dddd7c012dcbef8a6f
|
7
|
+
data.tar.gz: 3990872125e3d7700ee9b7902468f7e4eb9beb623cf948e044aae4bc369c0ca35b71722da488d72da0d5aa6d1b5fd3258b6e4038775b12029816be7e15461b60
|
@@ -13,8 +13,12 @@ module Mongoid
|
|
13
13
|
klass.es_index_name
|
14
14
|
end
|
15
15
|
|
16
|
+
## mapping names should not be specified, it will direclty use the type from here, which will default to document.
|
17
|
+
## if specified, mapping name should be document.
|
18
|
+
## this was modified to set the type of all documents as "document", because in newer versions elasticsearch supports only one mapping/type per index.
|
16
19
|
def type
|
17
|
-
|
20
|
+
"document"
|
21
|
+
#klass.model_name.collection.singularize
|
18
22
|
end
|
19
23
|
|
20
24
|
def options
|
@@ -147,10 +147,15 @@ module Mongoid
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def multi_with_load
|
150
|
+
#puts "--------------- Inside multi with load -------------"
|
151
|
+
#puts "returned since hits were empty."
|
150
152
|
return [] if hits.empty?
|
151
|
-
|
153
|
+
#puts "hits not empty."
|
154
|
+
#type has been shorted out to be document_type
|
155
|
+
#type for all documents is the same and it is called 'document'
|
156
|
+
#so now the document_type is the actual class of the model.
|
152
157
|
records = {}
|
153
|
-
hits.group_by { |item| item['
|
158
|
+
hits.group_by { |item| item['_source']['document_type'] }.each do |type, items|
|
154
159
|
klass = find_klass(type)
|
155
160
|
####################################################
|
156
161
|
##
|
@@ -174,7 +179,7 @@ module Mongoid
|
|
174
179
|
records[type]||= []
|
175
180
|
records[type] << klass.find(h['_id'])
|
176
181
|
rescue => e
|
177
|
-
|
182
|
+
puts e.to_s
|
178
183
|
end
|
179
184
|
end
|
180
185
|
|
@@ -183,8 +188,8 @@ module Mongoid
|
|
183
188
|
# Reorder records to preserve the order from search results
|
184
189
|
hits.map do |item|
|
185
190
|
### THIS LINE WAS ADDED TO CHECK IF THE TYPE EXISTS.
|
186
|
-
if records[item['
|
187
|
-
records[item['
|
191
|
+
if records[item['_source']['document_type']]
|
192
|
+
records[item['_source']['document_type']].detect do |record|
|
188
193
|
record.id.to_s == item['_id'].to_s
|
189
194
|
end
|
190
195
|
end
|
@@ -193,7 +198,7 @@ module Mongoid
|
|
193
198
|
|
194
199
|
def multi_without_load
|
195
200
|
hits.map do |h|
|
196
|
-
klass = find_klass(h['
|
201
|
+
klass = find_klass(h['_source']['document_type'])
|
197
202
|
h[:_highlight] = h.delete('highlight') if h.key?('highlight')
|
198
203
|
source = h.delete('_source')
|
199
204
|
if defined?(Moped::BSON)
|
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.5
|
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-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|