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: 578a2f4897aa691d5e5be10fe7101e434b566795
4
- data.tar.gz: 37be0ba588cc85d59df49e520bcee7c34640f18e
3
+ metadata.gz: ed51025a8797c0ead1ce01e9bce500f465aeed22
4
+ data.tar.gz: 3e40c6978d0d607a0f6a0335a1389447285c7a4b
5
5
  SHA512:
6
- metadata.gz: a06026e6ea7f345909c325e3b671cc6236304154715295ba680141f32169a0446d990f889bdfe3d52c61e46bb3e65cd14436395833129f28caca8d72fe58fb0b
7
- data.tar.gz: adbf2fa97b6f63a9c2d2218e3a7ab1621609ba148f0070b5faefdffbca7cca3a561f1bbc4d6646cb3a0936c97a31765cd9c0c151431d640b8e1bdb59ad444594
6
+ metadata.gz: 6645b0ca4a9b00c7d390e4dfa8851bf6b547be099b14ec739d3b57d2650219bd907e8aa99c6c3d038a1120fc8dcdac9115f20322cc9457dddd7c012dcbef8a6f
7
+ data.tar.gz: 3990872125e3d7700ee9b7902468f7e4eb9beb623cf948e044aae4bc369c0ca35b71722da488d72da0d5aa6d1b5fd3258b6e4038775b12029816be7e15461b60
@@ -79,6 +79,7 @@ module Mongoid
79
79
  search({body: {query: {match_all: {}}}}, options)
80
80
  end
81
81
 
82
+
82
83
  def options_for(obj)
83
84
  {id: obj.id.to_s}.merge type_options
84
85
  end
@@ -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
- klass.model_name.collection.singularize
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['_type'] }.each do |type, items|
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['_type']]
187
- records[item['_type']].detect do |record|
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['_type'])
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)
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Elasticsearch
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  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
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-07-04 00:00:00.000000000 Z
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid