cequel.rb
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
cequel =
Cequel.connect(
host: "127.0.0.1",
port: 9042,
keyspace: "searchkick_test",
default_consistency: :all
)
cequel.logger = $logger
cequel.schema.drop! if cequel.schema.exists?
cequel.schema.create!
Cequel::Record.connection = cequel
class Product
include Cequel::Record
key :id, :uuid, auto: true
column :name, :text, index: true
column :store_id, :int
column :in_stock, :boolean
column :backordered, :boolean
column :orders_count, :int
column :found_rate, :decimal
column :price, :int
column :color, :text
column :latitude, :decimal
column :longitude, :decimal
column :description, :text
column :alt_description, :text
column :created_at, :timestamp
end
class Store
include Cequel::Record
key :id, :timeuuid, auto: true
column :name, :text
# has issue with id serialization
def search_data
{
name: name
}
end
end
class Region
include Cequel::Record
key :id, :timeuuid, auto: true
column :name, :text
column :text, :text
end
class Speaker
include Cequel::Record
key :id, :timeuuid, auto: true
column :name, :text
end
class Animal
include Cequel::Record
key :id, :timeuuid, auto: true
column :name, :text
# has issue with id serialization
def search_data
{
name: name
}
end
end
class Dog < Animal
end
class Cat < Animal
end
class Sku
include Cequel::Record
key :id, :uuid
column :name, :text
end
class Song
include Cequel::Record
key :id, :timeuuid, auto: true
column :name, :text
end
[Product, Store, Region, Speaker, Animal, Sku, Song].each(&:synchronize_schema)