mongoid-sphinx 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ module Mongoid
|
|
8
8
|
while true
|
9
9
|
id = 100000000000000000000000 + rand(4294967294) # 4,294,967,295 is the theoretical max number of documents a 32 bit sphinx install can index
|
10
10
|
candidate = id.to_s
|
11
|
-
|
11
|
+
|
12
12
|
begin
|
13
13
|
@document.class.find(candidate) # Resource not found exception if available
|
14
14
|
rescue Mongoid::Errors::DocumentNotFound
|
@@ -62,20 +62,20 @@ module Mongoid
|
|
62
62
|
end
|
63
63
|
puts '</sphinx:schema>'
|
64
64
|
|
65
|
-
self.all.each do |
|
66
|
-
sphinx_compatible_id =
|
65
|
+
self.all.each do |document|
|
66
|
+
sphinx_compatible_id = document['_id'].to_s.to_i - 100000000000000000000000
|
67
67
|
if sphinx_compatible_id > 0
|
68
68
|
puts "<sphinx:document id=\"#{sphinx_compatible_id}\">"
|
69
69
|
|
70
70
|
puts "<classname>#{self.to_s}</classname>"
|
71
71
|
self.search_fields.each do |key|
|
72
|
-
puts "<#{key}><![CDATA[#{
|
72
|
+
puts "<#{key}><![CDATA[#{document.send(key.to_s)}]]></#{key}>"
|
73
73
|
end
|
74
74
|
self.search_attributes.each do |key, value|
|
75
75
|
value = case value
|
76
|
-
when 'bool' :
|
77
|
-
when 'timestamp' :
|
78
|
-
else
|
76
|
+
when 'bool' : document.send(key.to_s) ? 1 : 0
|
77
|
+
when 'timestamp' : document.send(key.to_s).to_i
|
78
|
+
else document.send(key.to_s).to_s
|
79
79
|
end
|
80
80
|
puts "<#{key}>#{value}</#{key}>"
|
81
81
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.9
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Hodgson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-26 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|