plain_search 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +135 -0
  4. data/Rakefile +34 -0
  5. data/lib/plain_search.rb +6 -0
  6. data/lib/plain_search/concern.rb +186 -0
  7. data/lib/plain_search/railtie.rb +13 -0
  8. data/lib/plain_search/version.rb +3 -0
  9. data/lib/tasks/plain_search.rake +19 -0
  10. data/test/dummy/README.rdoc +28 -0
  11. data/test/dummy/Rakefile +6 -0
  12. data/test/dummy/app/assets/javascripts/application.js +13 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  14. data/test/dummy/app/controllers/application_controller.rb +5 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/models/company.rb +3 -0
  17. data/test/dummy/app/models/dossier.rb +2 -0
  18. data/test/dummy/app/models/employee.rb +3 -0
  19. data/test/dummy/app/models/search_term.rb +3 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/test/dummy/bin/bundle +3 -0
  22. data/test/dummy/bin/rails +4 -0
  23. data/test/dummy/bin/rake +4 -0
  24. data/test/dummy/bin/setup +29 -0
  25. data/test/dummy/config.ru +4 -0
  26. data/test/dummy/config/application.rb +26 -0
  27. data/test/dummy/config/boot.rb +5 -0
  28. data/test/dummy/config/database.yml +25 -0
  29. data/test/dummy/config/environment.rb +5 -0
  30. data/test/dummy/config/environments/development.rb +41 -0
  31. data/test/dummy/config/environments/production.rb +79 -0
  32. data/test/dummy/config/environments/test.rb +42 -0
  33. data/test/dummy/config/initializers/assets.rb +11 -0
  34. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  36. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/test/dummy/config/initializers/inflections.rb +16 -0
  38. data/test/dummy/config/initializers/mime_types.rb +4 -0
  39. data/test/dummy/config/initializers/session_store.rb +3 -0
  40. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  41. data/test/dummy/config/locales/en.yml +23 -0
  42. data/test/dummy/config/routes.rb +56 -0
  43. data/test/dummy/config/secrets.yml +22 -0
  44. data/test/dummy/db/development.sqlite3 +0 -0
  45. data/test/dummy/db/migrate/20151013022315_create_base_tables.rb +32 -0
  46. data/test/dummy/db/schema.rb +47 -0
  47. data/test/dummy/db/test.sqlite3 +0 -0
  48. data/test/dummy/log/development.log +340 -0
  49. data/test/dummy/log/test.log +3615 -0
  50. data/test/dummy/public/404.html +67 -0
  51. data/test/dummy/public/422.html +67 -0
  52. data/test/dummy/public/500.html +66 -0
  53. data/test/dummy/public/favicon.ico +0 -0
  54. data/test/plain_search_test.rb +136 -0
  55. data/test/test_helper.rb +19 -0
  56. metadata +176 -0
@@ -0,0 +1,3615 @@
1
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
3
+  (0.0ms) select sqlite_version(*)
4
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
+  (0.1ms) SELECT version FROM "schema_migrations"
6
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
7
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
8
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
9
+  (1.2ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "gender" varchar(255), "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "state" varchar(255), "phone" varchar(255), "mobile" varchar(255), "email" varchar(255), "profession" varchar(255)) 
10
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
11
+  (0.1ms) select sqlite_version(*)
12
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
13
+  (0.1ms) SELECT version FROM "schema_migrations"
14
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
15
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
16
+  (0.1ms) begin transaction
17
+ --------------------------------
18
+ PlainSearchTest: test_by_example
19
+ --------------------------------
20
+  (0.0ms) rollback transaction
21
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
22
+  (1.1ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "gender" varchar(255), "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "state" varchar(255), "phone" varchar(255), "mobile" varchar(255), "email" varchar(255), "profession" varchar(255)) 
23
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
24
+  (0.1ms) select sqlite_version(*)
25
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26
+  (0.1ms) SELECT version FROM "schema_migrations"
27
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
28
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
29
+  (0.1ms) begin transaction
30
+ --------------------------------
31
+ PlainSearchTest: test_by_example
32
+ --------------------------------
33
+  (0.0ms) rollback transaction
34
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
35
+  (1.4ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "gender" varchar(255), "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "state" varchar(255), "phone" varchar(255), "mobile" varchar(255), "email" varchar(255), "profession" varchar(255)) 
36
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
37
+  (0.1ms) select sqlite_version(*)
38
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
39
+  (0.1ms) SELECT version FROM "schema_migrations"
40
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
41
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
42
+  (0.1ms) begin transaction
43
+ --------------------------------
44
+ PlainSearchTest: test_by_example
45
+ --------------------------------
46
+  (0.0ms) rollback transaction
47
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
48
+  (1.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
49
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
50
+  (0.1ms) select sqlite_version(*)
51
+  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
52
+  (0.1ms) SELECT version FROM "schema_migrations"
53
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
54
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
55
+  (0.1ms) begin transaction
56
+ --------------------------------
57
+ PlainSearchTest: test_by_example
58
+ --------------------------------
59
+  (0.1ms) SAVEPOINT active_record_1
60
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
61
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
62
+  (0.4ms) rollback transaction
63
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
64
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
65
+  (0.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
66
+  (0.0ms) select sqlite_version(*)
67
+  (0.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
68
+  (0.1ms) SELECT version FROM "schema_migrations"
69
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
70
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
71
+  (0.1ms) begin transaction
72
+ --------------------------------
73
+ PlainSearchTest: test_by_example
74
+ --------------------------------
75
+  (0.0ms) SAVEPOINT active_record_1
76
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
77
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
78
+  (0.3ms) rollback transaction
79
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
80
+  (0.8ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
81
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
82
+  (0.0ms) select sqlite_version(*)
83
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
84
+  (0.1ms) SELECT version FROM "schema_migrations"
85
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
86
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
87
+  (0.4ms) begin transaction
88
+ --------------------------------
89
+ PlainSearchTest: test_by_example
90
+ --------------------------------
91
+  (0.0ms) SAVEPOINT active_record_1
92
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
93
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
94
+  (0.3ms) rollback transaction
95
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
96
+  (1.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
97
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
98
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
99
+  (0.1ms) select sqlite_version(*)
100
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
101
+  (0.1ms) SELECT version FROM "schema_migrations"
102
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
103
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
104
+  (0.1ms) begin transaction
105
+ --------------------------------
106
+ PlainSearchTest: test_by_example
107
+ --------------------------------
108
+  (0.0ms) SAVEPOINT active_record_1
109
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
110
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
111
+  (0.3ms) rollback transaction
112
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
113
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
114
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
115
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
116
+  (0.0ms) select sqlite_version(*)
117
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
118
+  (0.1ms) SELECT version FROM "schema_migrations"
119
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
120
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
121
+  (0.1ms) begin transaction
122
+ --------------------------------
123
+ PlainSearchTest: test_by_example
124
+ --------------------------------
125
+  (0.0ms) SAVEPOINT active_record_1
126
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
127
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
128
+  (0.7ms) rollback transaction
129
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
130
+  (1.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
131
+  (0.7ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
132
+  (0.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
133
+  (0.0ms) select sqlite_version(*)
134
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
135
+  (0.1ms) SELECT version FROM "schema_migrations"
136
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
137
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
138
+  (0.1ms) begin transaction
139
+ --------------------------------
140
+ PlainSearchTest: test_by_example
141
+ --------------------------------
142
+  (0.0ms) SAVEPOINT active_record_1
143
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
144
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
145
+  (0.3ms) rollback transaction
146
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
147
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
148
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
149
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
150
+  (0.1ms) select sqlite_version(*)
151
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
152
+  (0.1ms) SELECT version FROM "schema_migrations"
153
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
154
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
155
+  (0.1ms) begin transaction
156
+ --------------------------------
157
+ PlainSearchTest: test_by_example
158
+ --------------------------------
159
+  (0.0ms) SAVEPOINT active_record_1
160
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
161
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
162
+  (0.2ms) rollback transaction
163
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
164
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
165
+  (0.7ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
166
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
167
+  (0.1ms) select sqlite_version(*)
168
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
169
+  (0.1ms) SELECT version FROM "schema_migrations"
170
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
171
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
172
+  (0.1ms) begin transaction
173
+ --------------------------------
174
+ PlainSearchTest: test_by_example
175
+ --------------------------------
176
+  (0.0ms) SAVEPOINT active_record_1
177
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
178
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
179
+  (0.3ms) rollback transaction
180
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
181
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
182
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
183
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
184
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
185
+  (0.1ms) select sqlite_version(*)
186
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
187
+  (0.1ms) SELECT version FROM "schema_migrations"
188
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
189
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
190
+  (0.1ms) begin transaction
191
+ --------------------------------
192
+ PlainSearchTest: test_by_example
193
+ --------------------------------
194
+  (0.0ms) SAVEPOINT active_record_1
195
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
196
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
197
+  (0.3ms) rollback transaction
198
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
199
+  (1.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
200
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
201
+  (0.6ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
202
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
203
+  (0.1ms) select sqlite_version(*)
204
+  (0.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
205
+  (0.1ms) SELECT version FROM "schema_migrations"
206
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
207
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
208
+  (0.1ms) begin transaction
209
+ --------------------------------
210
+ PlainSearchTest: test_by_example
211
+ --------------------------------
212
+  (0.2ms) SAVEPOINT active_record_1
213
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
214
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
215
+  (0.3ms) rollback transaction
216
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
217
+  (2.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
218
+  (1.1ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
219
+  (1.1ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
220
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
221
+  (0.1ms) select sqlite_version(*)
222
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
223
+  (0.1ms) SELECT version FROM "schema_migrations"
224
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
225
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
226
+  (0.1ms) begin transaction
227
+ --------------------------------
228
+ PlainSearchTest: test_by_example
229
+ --------------------------------
230
+  (0.0ms) SAVEPOINT active_record_1
231
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
232
+  (0.0ms) RELEASE SAVEPOINT active_record_1
233
+  (0.0ms) SAVEPOINT active_record_1
234
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
235
+  (0.0ms) RELEASE SAVEPOINT active_record_1
236
+  (0.0ms) SAVEPOINT active_record_1
237
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
238
+  (0.0ms) RELEASE SAVEPOINT active_record_1
239
+  (0.3ms) SAVEPOINT active_record_1
240
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
241
+  (0.0ms) RELEASE SAVEPOINT active_record_1
242
+  (0.1ms) SAVEPOINT active_record_1
243
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
244
+  (0.0ms) RELEASE SAVEPOINT active_record_1
245
+  (0.0ms) SAVEPOINT active_record_1
246
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
247
+  (0.0ms) RELEASE SAVEPOINT active_record_1
248
+  (0.0ms) SAVEPOINT active_record_1
249
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
250
+  (0.0ms) RELEASE SAVEPOINT active_record_1
251
+  (0.0ms) SAVEPOINT active_record_1
252
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
253
+  (0.0ms) RELEASE SAVEPOINT active_record_1
254
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
255
+ FROM (
256
+ SELECT
257
+ CASE
258
+ WHEN search_terms.source = 'first_name' then 10
259
+ WHEN search_terms.source = 'last_name' then 10
260
+ WHEN search_terms.source = 'profession' then 5
261
+ WHEN search_terms.source = 'address' then 1
262
+ WHEN search_terms.source = 'zip_code' then 1
263
+ WHEN search_terms.source = 'city' then 1
264
+ ELSE 0
265
+ END AS match_score,
266
+ employees.*
267
+ FROM employees
268
+ JOIN search_terms
269
+ ON search_terms.findable_id = employees.id
270
+ AND search_terms.findable_type = 'Employee'
271
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
272
+ ) AS e1
273
+ GROUP BY e1.id
274
+ ORDER BY score DESC
275
+
276
+  (0.5ms) rollback transaction
277
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
278
+  (1.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
279
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
280
+  (1.0ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
281
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
282
+  (0.1ms) select sqlite_version(*)
283
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
284
+  (0.1ms) SELECT version FROM "schema_migrations"
285
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
286
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
287
+  (0.1ms) begin transaction
288
+ --------------------------------
289
+ PlainSearchTest: test_by_example
290
+ --------------------------------
291
+  (0.0ms) SAVEPOINT active_record_1
292
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
293
+  (0.0ms) RELEASE SAVEPOINT active_record_1
294
+  (0.0ms) SAVEPOINT active_record_1
295
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
296
+  (0.0ms) RELEASE SAVEPOINT active_record_1
297
+  (0.0ms) SAVEPOINT active_record_1
298
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
299
+  (0.1ms) RELEASE SAVEPOINT active_record_1
300
+  (0.0ms) SAVEPOINT active_record_1
301
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
302
+  (0.0ms) RELEASE SAVEPOINT active_record_1
303
+  (0.0ms) SAVEPOINT active_record_1
304
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
305
+  (0.0ms) RELEASE SAVEPOINT active_record_1
306
+  (0.0ms) SAVEPOINT active_record_1
307
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
308
+  (0.0ms) RELEASE SAVEPOINT active_record_1
309
+  (0.0ms) SAVEPOINT active_record_1
310
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
311
+  (0.0ms) RELEASE SAVEPOINT active_record_1
312
+  (0.0ms) SAVEPOINT active_record_1
313
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
314
+  (0.0ms) RELEASE SAVEPOINT active_record_1
315
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
316
+ FROM (
317
+ SELECT
318
+ CASE
319
+ WHEN search_terms.source = 'first_name' then 10
320
+ WHEN search_terms.source = 'last_name' then 10
321
+ WHEN search_terms.source = 'profession' then 5
322
+ WHEN search_terms.source = 'address' then 1
323
+ WHEN search_terms.source = 'zip_code' then 1
324
+ WHEN search_terms.source = 'city' then 1
325
+ ELSE 0
326
+ END AS match_score,
327
+ employees.*
328
+ FROM employees
329
+ JOIN search_terms
330
+ ON search_terms.findable_id = employees.id
331
+ AND search_terms.findable_type = 'Employee'
332
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
333
+ ) AS e1
334
+ GROUP BY e1.id
335
+ ORDER BY score DESC
336
+
337
+  (0.5ms) rollback transaction
338
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
339
+  (1.6ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
340
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
341
+  (0.9ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
342
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
343
+  (0.0ms) select sqlite_version(*)
344
+  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
345
+  (0.1ms) SELECT version FROM "schema_migrations"
346
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
347
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
348
+  (0.1ms) begin transaction
349
+ --------------------------------
350
+ PlainSearchTest: test_by_example
351
+ --------------------------------
352
+  (0.1ms) SAVEPOINT active_record_1
353
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
354
+  (0.0ms) RELEASE SAVEPOINT active_record_1
355
+  (0.0ms) SAVEPOINT active_record_1
356
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
357
+  (0.0ms) RELEASE SAVEPOINT active_record_1
358
+  (0.0ms) SAVEPOINT active_record_1
359
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
360
+  (0.0ms) RELEASE SAVEPOINT active_record_1
361
+  (0.0ms) SAVEPOINT active_record_1
362
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
363
+  (0.0ms) RELEASE SAVEPOINT active_record_1
364
+  (0.0ms) SAVEPOINT active_record_1
365
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
366
+  (0.0ms) RELEASE SAVEPOINT active_record_1
367
+  (0.0ms) SAVEPOINT active_record_1
368
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
369
+  (0.0ms) RELEASE SAVEPOINT active_record_1
370
+  (0.0ms) SAVEPOINT active_record_1
371
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
372
+  (0.0ms) RELEASE SAVEPOINT active_record_1
373
+  (0.0ms) SAVEPOINT active_record_1
374
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
375
+  (0.1ms) RELEASE SAVEPOINT active_record_1
376
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
377
+ FROM (
378
+ SELECT
379
+ CASE
380
+ WHEN search_terms.source = 'first_name' then 10
381
+ WHEN search_terms.source = 'last_name' then 10
382
+ WHEN search_terms.source = 'profession' then 5
383
+ WHEN search_terms.source = 'address' then 1
384
+ WHEN search_terms.source = 'zip_code' then 1
385
+ WHEN search_terms.source = 'city' then 1
386
+ ELSE 0
387
+ END AS match_score,
388
+ employees.*
389
+ FROM employees
390
+ JOIN search_terms
391
+ ON search_terms.findable_id = employees.id
392
+ AND search_terms.findable_type = 'Employee'
393
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
394
+ ) AS e1
395
+ GROUP BY e1.id
396
+ ORDER BY score DESC
397
+
398
+  (0.6ms) rollback transaction
399
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
400
+  (2.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
401
+  (1.2ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
402
+  (1.2ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
403
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
404
+  (0.2ms) select sqlite_version(*)
405
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
406
+  (0.1ms) SELECT version FROM "schema_migrations"
407
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
408
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
409
+  (0.1ms) begin transaction
410
+ --------------------------------
411
+ PlainSearchTest: test_by_example
412
+ --------------------------------
413
+  (0.0ms) SAVEPOINT active_record_1
414
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
415
+  (0.0ms) RELEASE SAVEPOINT active_record_1
416
+  (0.0ms) SAVEPOINT active_record_1
417
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
418
+  (0.0ms) RELEASE SAVEPOINT active_record_1
419
+  (0.0ms) SAVEPOINT active_record_1
420
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
421
+  (0.0ms) RELEASE SAVEPOINT active_record_1
422
+  (0.0ms) SAVEPOINT active_record_1
423
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
424
+  (0.0ms) RELEASE SAVEPOINT active_record_1
425
+  (0.0ms) SAVEPOINT active_record_1
426
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
427
+  (0.0ms) RELEASE SAVEPOINT active_record_1
428
+  (0.0ms) SAVEPOINT active_record_1
429
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
430
+  (0.0ms) RELEASE SAVEPOINT active_record_1
431
+  (0.0ms) SAVEPOINT active_record_1
432
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
433
+  (0.0ms) RELEASE SAVEPOINT active_record_1
434
+  (0.0ms) SAVEPOINT active_record_1
435
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
436
+  (0.0ms) RELEASE SAVEPOINT active_record_1
437
+  (0.0ms) SAVEPOINT active_record_1
438
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
439
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
440
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
441
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
442
+  (0.6ms) rollback transaction
443
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
444
+  (1.2ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
445
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
446
+  (0.7ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
447
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
448
+  (0.1ms) select sqlite_version(*)
449
+  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
450
+  (0.1ms) SELECT version FROM "schema_migrations"
451
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
452
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
453
+  (0.1ms) begin transaction
454
+ --------------------------------
455
+ PlainSearchTest: test_by_example
456
+ --------------------------------
457
+  (0.0ms) SAVEPOINT active_record_1
458
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
459
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
460
+  (0.3ms) rollback transaction
461
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
462
+  (2.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
463
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
464
+  (0.9ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
465
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
466
+  (0.0ms) select sqlite_version(*)
467
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
468
+  (0.1ms) SELECT version FROM "schema_migrations"
469
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
470
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
471
+  (0.1ms) begin transaction
472
+ --------------------------------
473
+ PlainSearchTest: test_by_example
474
+ --------------------------------
475
+  (0.1ms) SAVEPOINT active_record_1
476
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
477
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
478
+  (0.4ms) rollback transaction
479
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
480
+  (1.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
481
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
482
+  (1.0ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
483
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
484
+  (0.1ms) select sqlite_version(*)
485
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
486
+  (0.1ms) SELECT version FROM "schema_migrations"
487
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
488
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
489
+  (0.1ms) begin transaction
490
+ --------------------------------
491
+ PlainSearchTest: test_by_example
492
+ --------------------------------
493
+  (0.0ms) SAVEPOINT active_record_1
494
+ SQL (0.7ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
495
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
496
+  (0.3ms) rollback transaction
497
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
498
+  (1.1ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
499
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
500
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
501
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
502
+  (0.1ms) select sqlite_version(*)
503
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
504
+  (0.1ms) SELECT version FROM "schema_migrations"
505
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
506
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
507
+  (0.1ms) begin transaction
508
+ --------------------------------
509
+ PlainSearchTest: test_by_example
510
+ --------------------------------
511
+  (0.0ms) SAVEPOINT active_record_1
512
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
513
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
514
+  (0.3ms) rollback transaction
515
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
516
+  (2.3ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
517
+  (1.3ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
518
+  (1.2ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
519
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
520
+  (0.1ms) select sqlite_version(*)
521
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
522
+  (0.1ms) SELECT version FROM "schema_migrations"
523
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
524
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
525
+  (0.1ms) begin transaction
526
+ --------------------------------
527
+ PlainSearchTest: test_by_example
528
+ --------------------------------
529
+  (0.0ms) SAVEPOINT active_record_1
530
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
531
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
532
+  (0.8ms) rollback transaction
533
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
534
+  (1.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
535
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
536
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
537
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
538
+  (0.1ms) select sqlite_version(*)
539
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
540
+  (0.1ms) SELECT version FROM "schema_migrations"
541
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
542
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
543
+  (0.1ms) begin transaction
544
+ --------------------------------
545
+ PlainSearchTest: test_by_example
546
+ --------------------------------
547
+  (0.0ms) SAVEPOINT active_record_1
548
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
549
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
550
+  (0.9ms) rollback transaction
551
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
552
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
553
+  (1.0ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
554
+  (0.9ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
555
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
556
+  (0.1ms) select sqlite_version(*)
557
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
558
+  (0.1ms) SELECT version FROM "schema_migrations"
559
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
560
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
561
+  (0.1ms) begin transaction
562
+ --------------------------------
563
+ PlainSearchTest: test_by_example
564
+ --------------------------------
565
+  (0.1ms) SAVEPOINT active_record_1
566
+ SQL (0.5ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
567
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
568
+  (0.9ms) rollback transaction
569
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
570
+  (2.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
571
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
572
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
573
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
574
+  (0.1ms) select sqlite_version(*)
575
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
576
+  (0.1ms) SELECT version FROM "schema_migrations"
577
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
578
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
579
+  (0.1ms) begin transaction
580
+ --------------------------------
581
+ PlainSearchTest: test_by_example
582
+ --------------------------------
583
+  (0.0ms) SAVEPOINT active_record_1
584
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
585
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
586
+  (0.8ms) rollback transaction
587
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
588
+  (1.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
589
+  (0.7ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
590
+  (0.7ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
591
+  (0.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
592
+  (0.0ms) select sqlite_version(*)
593
+  (0.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
594
+  (0.1ms) SELECT version FROM "schema_migrations"
595
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
596
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
597
+  (0.1ms) begin transaction
598
+ --------------------------------
599
+ PlainSearchTest: test_by_example
600
+ --------------------------------
601
+  (0.0ms) SAVEPOINT active_record_1
602
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
603
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
604
+  (0.8ms) rollback transaction
605
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
606
+  (2.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
607
+  (1.0ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
608
+  (0.9ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
609
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
610
+  (0.1ms) select sqlite_version(*)
611
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
612
+  (0.1ms) SELECT version FROM "schema_migrations"
613
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
614
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
615
+  (0.1ms) begin transaction
616
+ --------------------------------
617
+ PlainSearchTest: test_by_example
618
+ --------------------------------
619
+  (0.1ms) SAVEPOINT active_record_1
620
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
621
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
622
+  (0.3ms) rollback transaction
623
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
624
+  (1.1ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
625
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
626
+  (0.7ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
627
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
628
+  (0.1ms) select sqlite_version(*)
629
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
630
+  (0.1ms) SELECT version FROM "schema_migrations"
631
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
632
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
633
+  (0.1ms) begin transaction
634
+ --------------------------------
635
+ PlainSearchTest: test_by_example
636
+ --------------------------------
637
+  (0.1ms) SAVEPOINT active_record_1
638
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
639
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
640
+  (0.4ms) rollback transaction
641
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
642
+  (1.1ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
643
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
644
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
645
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
646
+  (0.0ms) select sqlite_version(*)
647
+  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
648
+  (0.1ms) SELECT version FROM "schema_migrations"
649
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
650
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
651
+  (0.1ms) begin transaction
652
+ --------------------------------
653
+ PlainSearchTest: test_by_example
654
+ --------------------------------
655
+  (0.0ms) SAVEPOINT active_record_1
656
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
657
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
658
+  (0.4ms) rollback transaction
659
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
660
+  (0.9ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
661
+  (0.7ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
662
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
663
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
664
+  (0.0ms) select sqlite_version(*)
665
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
666
+  (0.1ms) SELECT version FROM "schema_migrations"
667
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
668
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
669
+  (0.1ms) begin transaction
670
+ --------------------------------
671
+ PlainSearchTest: test_by_example
672
+ --------------------------------
673
+  (0.1ms) SAVEPOINT active_record_1
674
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
675
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
676
+  (0.3ms) rollback transaction
677
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
678
+  (1.1ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
679
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
680
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
681
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
682
+  (0.0ms) select sqlite_version(*)
683
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
684
+  (0.1ms) SELECT version FROM "schema_migrations"
685
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
686
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
687
+  (0.1ms) begin transaction
688
+ --------------------------------
689
+ PlainSearchTest: test_by_example
690
+ --------------------------------
691
+  (0.0ms) SAVEPOINT active_record_1
692
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
693
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 1], ["findable_type", "Employee"]]
694
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
695
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
696
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
697
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
698
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
699
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
700
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
701
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
702
+  (0.0ms) RELEASE SAVEPOINT active_record_1
703
+  (0.0ms) SAVEPOINT active_record_1
704
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
705
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 2], ["findable_type", "Employee"]]
706
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
707
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
708
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
709
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
710
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
711
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
712
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
713
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
714
+  (0.0ms) RELEASE SAVEPOINT active_record_1
715
+  (0.0ms) SAVEPOINT active_record_1
716
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
717
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 3], ["findable_type", "Employee"]]
718
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
719
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
720
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
721
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
722
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
723
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
724
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
725
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
726
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
727
+  (0.0ms) RELEASE SAVEPOINT active_record_1
728
+  (0.0ms) SAVEPOINT active_record_1
729
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
730
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 4], ["findable_type", "Employee"]]
731
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
732
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
733
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
734
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
735
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
736
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
737
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
738
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
739
+  (0.0ms) RELEASE SAVEPOINT active_record_1
740
+  (0.0ms) SAVEPOINT active_record_1
741
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
742
+  (0.0ms) RELEASE SAVEPOINT active_record_1
743
+  (0.0ms) SAVEPOINT active_record_1
744
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
745
+  (0.0ms) RELEASE SAVEPOINT active_record_1
746
+  (0.1ms) SAVEPOINT active_record_1
747
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
748
+  (0.0ms) RELEASE SAVEPOINT active_record_1
749
+  (0.0ms) SAVEPOINT active_record_1
750
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
751
+  (0.0ms) RELEASE SAVEPOINT active_record_1
752
+ Employee Load (0.2ms)  SELECT SUM(e1.match_score) AS score, e1.*
753
+ FROM (
754
+ SELECT
755
+ CASE
756
+ WHEN search_terms.source = 'first_name' then 10
757
+ WHEN search_terms.source = 'last_name' then 10
758
+ WHEN search_terms.source = 'profession' then 5
759
+ WHEN search_terms.source = 'address' then 1
760
+ WHEN search_terms.source = 'zip_code' then 1
761
+ WHEN search_terms.source = 'city' then 1
762
+ ELSE 0
763
+ END AS match_score,
764
+ employees.*
765
+ FROM employees
766
+ JOIN search_terms
767
+ ON search_terms.findable_id = employees.id
768
+ AND search_terms.findable_type = 'Employee'
769
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
770
+ ) AS e1
771
+ GROUP BY e1.id
772
+ ORDER BY score DESC
773
+ 
774
+  (0.7ms) rollback transaction
775
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
776
+  (1.0ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
777
+  (0.8ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
778
+  (0.8ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
779
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
780
+  (0.1ms) select sqlite_version(*)
781
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
782
+  (0.1ms) SELECT version FROM "schema_migrations"
783
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
784
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
785
+  (0.1ms) begin transaction
786
+ --------------------------------
787
+ PlainSearchTest: test_by_example
788
+ --------------------------------
789
+  (0.1ms) SAVEPOINT active_record_1
790
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
791
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 1], ["findable_type", "Employee"]]
792
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
793
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
794
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
795
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
796
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
797
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
798
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
799
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
800
+  (0.0ms) RELEASE SAVEPOINT active_record_1
801
+  (0.0ms) SAVEPOINT active_record_1
802
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
803
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 2], ["findable_type", "Employee"]]
804
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
805
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
806
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
807
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
808
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
809
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
810
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
811
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
812
+  (0.0ms) RELEASE SAVEPOINT active_record_1
813
+  (0.0ms) SAVEPOINT active_record_1
814
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
815
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 3], ["findable_type", "Employee"]]
816
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
817
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
818
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
819
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
820
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
821
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
822
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
823
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
824
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
825
+  (0.0ms) RELEASE SAVEPOINT active_record_1
826
+  (0.0ms) SAVEPOINT active_record_1
827
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
828
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE "search_terms"."findable_id" = ? AND "search_terms"."findable_type" = ? AND "search_terms"."source" IN ('first_name', 'last_name', 'profession', 'address', 'zip_code', 'city') [["findable_id", 4], ["findable_type", "Employee"]]
829
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
830
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
831
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
832
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
833
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
834
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
835
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
836
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
837
+  (0.1ms) RELEASE SAVEPOINT active_record_1
838
+  (0.0ms) SAVEPOINT active_record_1
839
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
840
+  (0.0ms) RELEASE SAVEPOINT active_record_1
841
+  (0.0ms) SAVEPOINT active_record_1
842
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
843
+  (0.0ms) RELEASE SAVEPOINT active_record_1
844
+  (0.0ms) SAVEPOINT active_record_1
845
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
846
+  (0.0ms) RELEASE SAVEPOINT active_record_1
847
+  (0.0ms) SAVEPOINT active_record_1
848
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
849
+  (0.0ms) RELEASE SAVEPOINT active_record_1
850
+ Employee Load (0.2ms)  SELECT SUM(e1.match_score) AS score, e1.*
851
+ FROM (
852
+ SELECT
853
+ CASE
854
+ WHEN search_terms.source = 'first_name' then 10
855
+ WHEN search_terms.source = 'last_name' then 10
856
+ WHEN search_terms.source = 'profession' then 5
857
+ WHEN search_terms.source = 'address' then 1
858
+ WHEN search_terms.source = 'zip_code' then 1
859
+ WHEN search_terms.source = 'city' then 1
860
+ ELSE 0
861
+ END AS match_score,
862
+ employees.*
863
+ FROM employees
864
+ JOIN search_terms
865
+ ON search_terms.findable_id = employees.id
866
+ AND search_terms.findable_type = 'Employee'
867
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
868
+ ) AS e1
869
+ GROUP BY e1.id
870
+ ORDER BY score DESC
871
+ 
872
+  (0.6ms) rollback transaction
873
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
874
+  (1.7ms) CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255) NOT NULL, "last_name" varchar(255) NOT NULL, "address" varchar(255), "zip_code" varchar(255), "city" varchar(255), "phone" varchar(255), "email" varchar(255), "profession" varchar(255), "internal_remarks" varchar(255)) 
875
+  (0.9ms) CREATE TABLE "search_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term" varchar(255), "source" varchar(255), "findable_id" integer(4), "findable_type" varchar(255))
876
+  (0.7ms) CREATE TABLE "dossiers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "filename" varchar(255)) 
877
+  (0.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
878
+  (0.1ms) select sqlite_version(*)
879
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
880
+  (0.1ms) SELECT version FROM "schema_migrations"
881
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
882
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
883
+  (0.1ms) begin transaction
884
+ --------------------------------
885
+ PlainSearchTest: test_by_example
886
+ --------------------------------
887
+  (0.0ms) SAVEPOINT active_record_1
888
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
889
+  (0.0ms) RELEASE SAVEPOINT active_record_1
890
+  (0.0ms) SAVEPOINT active_record_1
891
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
892
+  (0.0ms) RELEASE SAVEPOINT active_record_1
893
+  (0.0ms) SAVEPOINT active_record_1
894
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
895
+  (0.0ms) RELEASE SAVEPOINT active_record_1
896
+  (0.0ms) SAVEPOINT active_record_1
897
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
898
+  (0.0ms) RELEASE SAVEPOINT active_record_1
899
+  (0.0ms) SAVEPOINT active_record_1
900
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
901
+  (0.0ms) RELEASE SAVEPOINT active_record_1
902
+  (0.0ms) SAVEPOINT active_record_1
903
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
904
+  (0.0ms) RELEASE SAVEPOINT active_record_1
905
+  (0.0ms) SAVEPOINT active_record_1
906
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
907
+  (0.0ms) RELEASE SAVEPOINT active_record_1
908
+  (0.0ms) SAVEPOINT active_record_1
909
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
910
+  (0.0ms) RELEASE SAVEPOINT active_record_1
911
+  (0.1ms) SAVEPOINT active_record_1
912
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
913
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
914
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
915
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
916
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
917
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
918
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
919
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
920
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
921
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
922
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
923
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
924
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
925
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
926
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
927
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
928
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
929
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
930
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
931
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
932
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
933
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
934
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
935
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
936
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
937
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
938
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
939
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
940
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
941
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
942
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
943
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
944
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
945
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
946
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
947
+  (0.0ms) RELEASE SAVEPOINT active_record_1
948
+ Employee Load (0.2ms)  SELECT SUM(e1.match_score) AS score, e1.*
949
+ FROM (
950
+ SELECT
951
+ CASE
952
+ WHEN search_terms.source = 'first_name' then 10
953
+ WHEN search_terms.source = 'last_name' then 10
954
+ WHEN search_terms.source = 'profession' then 5
955
+ WHEN search_terms.source = 'address' then 1
956
+ WHEN search_terms.source = 'zip_code' then 1
957
+ WHEN search_terms.source = 'city' then 1
958
+ ELSE 0
959
+ END AS match_score,
960
+ employees.*
961
+ FROM employees
962
+ JOIN search_terms
963
+ ON search_terms.findable_id = employees.id
964
+ AND search_terms.findable_type = 'Employee'
965
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
966
+ ) AS e1
967
+ GROUP BY e1.id
968
+ ORDER BY score DESC
969
+ 
970
+  (0.7ms) rollback transaction
971
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
972
+  (0.1ms) begin transaction
973
+ --------------------------------
974
+ PlainSearchTest: test_by_example
975
+ --------------------------------
976
+  (0.0ms) SAVEPOINT active_record_1
977
+ SQL (1.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
978
+  (0.1ms) RELEASE SAVEPOINT active_record_1
979
+  (0.0ms) SAVEPOINT active_record_1
980
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
981
+  (0.0ms) RELEASE SAVEPOINT active_record_1
982
+  (0.0ms) SAVEPOINT active_record_1
983
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
984
+  (0.0ms) RELEASE SAVEPOINT active_record_1
985
+  (0.0ms) SAVEPOINT active_record_1
986
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
987
+  (0.0ms) RELEASE SAVEPOINT active_record_1
988
+  (0.0ms) SAVEPOINT active_record_1
989
+ SQL (0.4ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
990
+  (0.1ms) RELEASE SAVEPOINT active_record_1
991
+  (0.0ms) SAVEPOINT active_record_1
992
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
993
+  (0.0ms) RELEASE SAVEPOINT active_record_1
994
+  (0.2ms) SAVEPOINT active_record_1
995
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
996
+  (0.0ms) RELEASE SAVEPOINT active_record_1
997
+  (0.0ms) SAVEPOINT active_record_1
998
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
999
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1000
+  (0.0ms) SAVEPOINT active_record_1
1001
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1002
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1003
+ SQL (0.5ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1004
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1005
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1006
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1007
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1008
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1009
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1010
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1011
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1012
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1013
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1014
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1015
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1016
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1017
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1018
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1019
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1020
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1021
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1022
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1023
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1024
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1025
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1026
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1027
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1028
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1029
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1030
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1031
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1032
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1033
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1034
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1035
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1036
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1037
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1038
+ FROM (
1039
+ SELECT
1040
+ CASE
1041
+ WHEN search_terms.source = 'first_name' then 10
1042
+ WHEN search_terms.source = 'last_name' then 10
1043
+ WHEN search_terms.source = 'profession' then 5
1044
+ WHEN search_terms.source = 'address' then 1
1045
+ WHEN search_terms.source = 'zip_code' then 1
1046
+ WHEN search_terms.source = 'city' then 1
1047
+ ELSE 0
1048
+ END AS match_score,
1049
+ employees.*
1050
+ FROM employees
1051
+ JOIN search_terms
1052
+ ON search_terms.findable_id = employees.id
1053
+ AND search_terms.findable_type = 'Employee'
1054
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1055
+ ) AS e1
1056
+ GROUP BY e1.id
1057
+ ORDER BY score DESC
1058
+
1059
+  (0.8ms) rollback transaction
1060
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1061
+  (0.1ms) begin transaction
1062
+ --------------------------------
1063
+ PlainSearchTest: test_by_example
1064
+ --------------------------------
1065
+  (0.0ms) SAVEPOINT active_record_1
1066
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1067
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1068
+  (0.2ms) SAVEPOINT active_record_1
1069
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1070
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1071
+  (0.0ms) SAVEPOINT active_record_1
1072
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1073
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1074
+  (0.2ms) SAVEPOINT active_record_1
1075
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1076
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1077
+  (0.0ms) SAVEPOINT active_record_1
1078
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1079
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1080
+  (0.0ms) SAVEPOINT active_record_1
1081
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar.pdf"]]
1082
+  (0.2ms) RELEASE SAVEPOINT active_record_1
1083
+  (0.0ms) SAVEPOINT active_record_1
1084
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas.pdf"]]
1085
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1086
+  (0.0ms) SAVEPOINT active_record_1
1087
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi.pdf"]]
1088
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1089
+  (0.0ms) SAVEPOINT active_record_1
1090
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1091
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1092
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1093
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1094
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1095
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1096
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1097
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1098
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1099
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1100
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1101
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1102
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1103
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1104
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1105
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1106
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1107
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1108
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1109
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1110
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1111
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1112
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1113
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1114
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1115
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1116
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1117
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1118
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1119
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1120
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1121
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1122
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1123
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1124
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1125
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1126
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1127
+ FROM (
1128
+ SELECT
1129
+ CASE
1130
+ WHEN search_terms.source = 'first_name' then 10
1131
+ WHEN search_terms.source = 'last_name' then 10
1132
+ WHEN search_terms.source = 'profession' then 5
1133
+ WHEN search_terms.source = 'address' then 1
1134
+ WHEN search_terms.source = 'zip_code' then 1
1135
+ WHEN search_terms.source = 'city' then 1
1136
+ ELSE 0
1137
+ END AS match_score,
1138
+ employees.*
1139
+ FROM employees
1140
+ JOIN search_terms
1141
+ ON search_terms.findable_id = employees.id
1142
+ AND search_terms.findable_type = 'Employee'
1143
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1144
+ ) AS e1
1145
+ GROUP BY e1.id
1146
+ ORDER BY score DESC
1147
+
1148
+  (1.2ms) rollback transaction
1149
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1150
+  (0.1ms) begin transaction
1151
+ --------------------------------
1152
+ PlainSearchTest: test_by_example
1153
+ --------------------------------
1154
+  (0.0ms) SAVEPOINT active_record_1
1155
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1156
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1157
+  (0.0ms) SAVEPOINT active_record_1
1158
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1159
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1160
+  (0.0ms) SAVEPOINT active_record_1
1161
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1162
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1163
+  (0.0ms) SAVEPOINT active_record_1
1164
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1165
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1166
+  (0.0ms) SAVEPOINT active_record_1
1167
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1168
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1169
+  (0.0ms) SAVEPOINT active_record_1
1170
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1171
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1172
+  (0.0ms) SAVEPOINT active_record_1
1173
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1174
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1175
+  (0.0ms) SAVEPOINT active_record_1
1176
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1177
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1178
+  (0.0ms) SAVEPOINT active_record_1
1179
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1180
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1181
+  (0.0ms) SAVEPOINT active_record_1
1182
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1183
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1184
+  (0.0ms) SAVEPOINT active_record_1
1185
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1186
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1187
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1188
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1189
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1190
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1191
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1192
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1193
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1194
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1195
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1196
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1197
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1198
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1199
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1200
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1201
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1202
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1203
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1204
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1205
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1206
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1207
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1208
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1209
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1210
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1211
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1212
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1213
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1214
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1215
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1216
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1217
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1218
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1219
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1220
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1221
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1222
+ FROM (
1223
+ SELECT
1224
+ CASE
1225
+ WHEN search_terms.source = 'first_name' then 10
1226
+ WHEN search_terms.source = 'last_name' then 10
1227
+ WHEN search_terms.source = 'profession' then 5
1228
+ WHEN search_terms.source = 'address' then 1
1229
+ WHEN search_terms.source = 'zip_code' then 1
1230
+ WHEN search_terms.source = 'city' then 1
1231
+ ELSE 0
1232
+ END AS match_score,
1233
+ employees.*
1234
+ FROM employees
1235
+ JOIN search_terms
1236
+ ON search_terms.findable_id = employees.id
1237
+ AND search_terms.findable_type = 'Employee'
1238
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1239
+ ) AS e1
1240
+ GROUP BY e1.id
1241
+ ORDER BY score DESC
1242
+
1243
+  (0.0ms) SAVEPOINT active_record_1
1244
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1245
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
1246
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1247
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1248
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1249
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1250
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1251
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1252
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
1253
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1254
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1255
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1256
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1257
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1258
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1259
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1260
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
1261
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1262
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1263
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1264
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
1265
+ FROM dossiers
1266
+ JOIN search_terms
1267
+ ON search_terms.findable_id = dossiers.id
1268
+ AND search_terms.findable_type = 'Dossier'
1269
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
1270
+ GROUP BY dossiers.id
1271
+ ORDER BY hits DESC
1272
+
1273
+  (1.6ms) rollback transaction
1274
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1275
+  (0.1ms) begin transaction
1276
+ --------------------------------
1277
+ PlainSearchTest: test_by_example
1278
+ --------------------------------
1279
+  (0.1ms) SAVEPOINT active_record_1
1280
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1281
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1282
+  (0.0ms) SAVEPOINT active_record_1
1283
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1284
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1285
+  (0.2ms) SAVEPOINT active_record_1
1286
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1287
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1288
+  (0.0ms) SAVEPOINT active_record_1
1289
+ SQL (0.1ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1290
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1291
+  (0.1ms) SAVEPOINT active_record_1
1292
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1293
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1294
+  (0.0ms) SAVEPOINT active_record_1
1295
+ SQL (0.3ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1296
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1297
+  (0.0ms) SAVEPOINT active_record_1
1298
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1299
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1300
+  (0.0ms) SAVEPOINT active_record_1
1301
+ SQL (0.3ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1302
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1303
+  (0.0ms) SAVEPOINT active_record_1
1304
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1305
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1306
+  (0.0ms) SAVEPOINT active_record_1
1307
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1308
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1309
+  (0.0ms) SAVEPOINT active_record_1
1310
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1311
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1312
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1313
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1314
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1315
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1316
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1317
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1318
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1319
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1320
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1321
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1322
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1323
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1324
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1325
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1326
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1327
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1328
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1329
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1330
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1331
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1332
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1333
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1334
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1335
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1336
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1337
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1338
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1339
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1340
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1341
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1342
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1343
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1344
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1345
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1346
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1347
+ FROM (
1348
+ SELECT
1349
+ CASE
1350
+ WHEN search_terms.source = 'first_name' then 10
1351
+ WHEN search_terms.source = 'last_name' then 10
1352
+ WHEN search_terms.source = 'profession' then 5
1353
+ WHEN search_terms.source = 'address' then 1
1354
+ WHEN search_terms.source = 'zip_code' then 1
1355
+ WHEN search_terms.source = 'city' then 1
1356
+ ELSE 0
1357
+ END AS match_score,
1358
+ employees.*
1359
+ FROM employees
1360
+ JOIN search_terms
1361
+ ON search_terms.findable_id = employees.id
1362
+ AND search_terms.findable_type = 'Employee'
1363
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1364
+ ) AS e1
1365
+ GROUP BY e1.id
1366
+ ORDER BY score DESC
1367
+
1368
+  (0.0ms) SAVEPOINT active_record_1
1369
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1370
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
1371
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1372
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1373
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1374
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1375
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1376
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1377
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
1378
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1379
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1380
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1381
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1382
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1383
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1384
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1385
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
1386
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1387
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1388
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1389
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
1390
+ FROM dossiers
1391
+ JOIN search_terms
1392
+ ON search_terms.findable_id = dossiers.id
1393
+ AND search_terms.findable_type = 'Dossier'
1394
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
1395
+ GROUP BY dossiers.id
1396
+ ORDER BY hits DESC
1397
+
1398
+  (0.7ms) rollback transaction
1399
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1400
+  (0.1ms) begin transaction
1401
+ --------------------------------
1402
+ PlainSearchTest: test_by_example
1403
+ --------------------------------
1404
+  (0.1ms) SAVEPOINT active_record_1
1405
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1406
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1407
+  (0.0ms) SAVEPOINT active_record_1
1408
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1409
+  (0.2ms) RELEASE SAVEPOINT active_record_1
1410
+  (0.0ms) SAVEPOINT active_record_1
1411
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1412
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1413
+  (0.0ms) SAVEPOINT active_record_1
1414
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1415
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1416
+  (0.0ms) SAVEPOINT active_record_1
1417
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1418
+  (0.2ms) RELEASE SAVEPOINT active_record_1
1419
+  (0.0ms) SAVEPOINT active_record_1
1420
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1421
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1422
+  (0.0ms) SAVEPOINT active_record_1
1423
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1424
+  (0.2ms) RELEASE SAVEPOINT active_record_1
1425
+  (0.0ms) SAVEPOINT active_record_1
1426
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1427
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1428
+  (0.0ms) SAVEPOINT active_record_1
1429
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1430
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1431
+  (0.0ms) SAVEPOINT active_record_1
1432
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1433
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1434
+  (0.1ms) SAVEPOINT active_record_1
1435
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1436
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1437
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1438
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1439
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1440
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1441
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1442
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1443
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1444
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1445
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1446
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1447
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1448
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1449
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1450
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1451
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1452
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1453
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1454
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1455
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1456
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1457
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1458
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1459
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1460
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1461
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1462
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1463
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1464
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1465
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1466
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1467
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1468
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1469
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1470
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1471
+ Employee Load (0.3ms) SELECT SUM(e1.match_score) AS score, e1.*
1472
+ FROM (
1473
+ SELECT
1474
+ CASE
1475
+ WHEN search_terms.source = 'first_name' then 10
1476
+ WHEN search_terms.source = 'last_name' then 10
1477
+ WHEN search_terms.source = 'profession' then 5
1478
+ WHEN search_terms.source = 'address' then 1
1479
+ WHEN search_terms.source = 'zip_code' then 1
1480
+ WHEN search_terms.source = 'city' then 1
1481
+ ELSE 0
1482
+ END AS match_score,
1483
+ employees.*
1484
+ FROM employees
1485
+ JOIN search_terms
1486
+ ON search_terms.findable_id = employees.id
1487
+ AND search_terms.findable_type = 'Employee'
1488
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1489
+ ) AS e1
1490
+ GROUP BY e1.id
1491
+ ORDER BY score DESC
1492
+
1493
+  (0.0ms) SAVEPOINT active_record_1
1494
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1495
+ Dossier Load (0.1ms) SELECT "dossiers".* FROM "dossiers"
1496
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1497
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1498
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1499
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1500
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1501
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1502
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
1503
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1504
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1505
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1506
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1507
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1508
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1509
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1510
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
1511
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1512
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1513
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1514
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
1515
+ FROM dossiers
1516
+ JOIN search_terms
1517
+ ON search_terms.findable_id = dossiers.id
1518
+ AND search_terms.findable_type = 'Dossier'
1519
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
1520
+ GROUP BY dossiers.id
1521
+ ORDER BY hits DESC
1522
+
1523
+  (1.3ms) rollback transaction
1524
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1525
+  (0.1ms) begin transaction
1526
+ --------------------------------
1527
+ PlainSearchTest: test_by_example
1528
+ --------------------------------
1529
+  (0.0ms) SAVEPOINT active_record_1
1530
+ SQL (0.5ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1531
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1532
+  (0.0ms) SAVEPOINT active_record_1
1533
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1534
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1535
+  (0.0ms) SAVEPOINT active_record_1
1536
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1537
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1538
+  (0.0ms) SAVEPOINT active_record_1
1539
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1540
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1541
+  (0.1ms) SAVEPOINT active_record_1
1542
+ SQL (0.2ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1543
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1544
+  (0.0ms) SAVEPOINT active_record_1
1545
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1546
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1547
+  (0.0ms) SAVEPOINT active_record_1
1548
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1549
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1550
+  (0.0ms) SAVEPOINT active_record_1
1551
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1552
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1553
+  (0.0ms) SAVEPOINT active_record_1
1554
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1555
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1556
+  (0.0ms) SAVEPOINT active_record_1
1557
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1558
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1559
+  (0.0ms) SAVEPOINT active_record_1
1560
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1561
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1562
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1563
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1564
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1565
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1566
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1567
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1568
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1569
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1570
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1571
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1572
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1573
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1574
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1575
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1576
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1577
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1578
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1579
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1580
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1581
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1582
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1583
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1584
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1585
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1586
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1587
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1588
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1589
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1590
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1591
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1592
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1593
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1594
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1595
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1596
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1597
+ FROM (
1598
+ SELECT
1599
+ CASE
1600
+ WHEN search_terms.source = 'first_name' then 10
1601
+ WHEN search_terms.source = 'last_name' then 10
1602
+ WHEN search_terms.source = 'profession' then 5
1603
+ WHEN search_terms.source = 'address' then 1
1604
+ WHEN search_terms.source = 'zip_code' then 1
1605
+ WHEN search_terms.source = 'city' then 1
1606
+ ELSE 0
1607
+ END AS match_score,
1608
+ employees.*
1609
+ FROM employees
1610
+ JOIN search_terms
1611
+ ON search_terms.findable_id = employees.id
1612
+ AND search_terms.findable_type = 'Employee'
1613
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1614
+ ) AS e1
1615
+ GROUP BY e1.id
1616
+ ORDER BY score DESC
1617
+
1618
+  (0.0ms) SAVEPOINT active_record_1
1619
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1620
+ Dossier Load (0.1ms) SELECT "dossiers".* FROM "dossiers"
1621
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1622
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1623
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1624
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1625
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1626
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1627
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
1628
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1629
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1630
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1631
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1632
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
1633
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1634
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1635
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1636
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1637
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1638
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1639
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
1640
+ FROM dossiers
1641
+ JOIN search_terms
1642
+ ON search_terms.findable_id = dossiers.id
1643
+ AND search_terms.findable_type = 'Dossier'
1644
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
1645
+ GROUP BY dossiers.id
1646
+ ORDER BY hits DESC
1647
+
1648
+  (0.7ms) rollback transaction
1649
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1650
+  (0.1ms) begin transaction
1651
+ --------------------------------
1652
+ PlainSearchTest: test_by_example
1653
+ --------------------------------
1654
+  (0.0ms) SAVEPOINT active_record_1
1655
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1656
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1657
+  (0.1ms) SAVEPOINT active_record_1
1658
+ SQL (0.4ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1659
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1660
+  (0.0ms) SAVEPOINT active_record_1
1661
+ SQL (0.1ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1662
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1663
+  (0.0ms) SAVEPOINT active_record_1
1664
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1665
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1666
+  (0.0ms) SAVEPOINT active_record_1
1667
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1668
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1669
+  (0.0ms) SAVEPOINT active_record_1
1670
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1671
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1672
+  (0.0ms) SAVEPOINT active_record_1
1673
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1674
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1675
+  (0.0ms) SAVEPOINT active_record_1
1676
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1677
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1678
+  (0.1ms) SAVEPOINT active_record_1
1679
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1680
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1681
+  (0.0ms) SAVEPOINT active_record_1
1682
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1683
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1684
+  (0.0ms) SAVEPOINT active_record_1
1685
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1686
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1687
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1688
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1689
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1690
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1691
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1692
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1693
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1694
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1695
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1696
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1697
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1698
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1699
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1700
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1701
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1702
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1703
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1704
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1705
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1706
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1707
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1708
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1709
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1710
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1711
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1712
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1713
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1714
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1715
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1716
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1717
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1718
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1719
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1720
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1721
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1722
+ FROM (
1723
+ SELECT
1724
+ CASE
1725
+ WHEN search_terms.source = 'first_name' then 10
1726
+ WHEN search_terms.source = 'last_name' then 10
1727
+ WHEN search_terms.source = 'profession' then 5
1728
+ WHEN search_terms.source = 'address' then 1
1729
+ WHEN search_terms.source = 'zip_code' then 1
1730
+ WHEN search_terms.source = 'city' then 1
1731
+ ELSE 0
1732
+ END AS match_score,
1733
+ employees.*
1734
+ FROM employees
1735
+ JOIN search_terms
1736
+ ON search_terms.findable_id = employees.id
1737
+ AND search_terms.findable_type = 'Employee'
1738
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1739
+ ) AS e1
1740
+ GROUP BY e1.id
1741
+ ORDER BY score DESC
1742
+
1743
+  (0.0ms) SAVEPOINT active_record_1
1744
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1745
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
1746
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1747
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1748
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1749
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1750
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1751
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1752
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
1753
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1754
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1755
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1756
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1757
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
1758
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1759
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1760
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1761
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1762
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1763
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1764
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
1765
+ FROM dossiers
1766
+ JOIN search_terms
1767
+ ON search_terms.findable_id = dossiers.id
1768
+ AND search_terms.findable_type = 'Dossier'
1769
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
1770
+ GROUP BY dossiers.id
1771
+ ORDER BY hits DESC
1772
+
1773
+  (0.7ms) rollback transaction
1774
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1775
+  (0.1ms) begin transaction
1776
+ --------------------------------
1777
+ PlainSearchTest: test_by_example
1778
+ --------------------------------
1779
+  (0.0ms) SAVEPOINT active_record_1
1780
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1781
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1782
+  (0.2ms) SAVEPOINT active_record_1
1783
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1784
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1785
+  (0.0ms) SAVEPOINT active_record_1
1786
+ SQL (0.1ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1787
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1788
+  (0.0ms) SAVEPOINT active_record_1
1789
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1790
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1791
+  (0.0ms) SAVEPOINT active_record_1
1792
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1793
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1794
+  (0.0ms) SAVEPOINT active_record_1
1795
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1796
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1797
+  (0.0ms) SAVEPOINT active_record_1
1798
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1799
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1800
+  (0.0ms) SAVEPOINT active_record_1
1801
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1802
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1803
+  (0.0ms) SAVEPOINT active_record_1
1804
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1805
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1806
+  (0.0ms) SAVEPOINT active_record_1
1807
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1808
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1809
+  (0.1ms) SAVEPOINT active_record_1
1810
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1811
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1812
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1813
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1814
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1815
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1816
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1817
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1818
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1819
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1820
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1821
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1822
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1823
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1824
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1825
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1826
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1827
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1828
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1829
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1830
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1831
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1832
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1833
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1834
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1835
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1836
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1837
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1838
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1839
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1840
+ SQL (8.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1841
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1842
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1843
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1844
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1845
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1846
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1847
+ FROM (
1848
+ SELECT
1849
+ CASE
1850
+ WHEN search_terms.source = 'first_name' then 10
1851
+ WHEN search_terms.source = 'last_name' then 10
1852
+ WHEN search_terms.source = 'profession' then 5
1853
+ WHEN search_terms.source = 'address' then 1
1854
+ WHEN search_terms.source = 'zip_code' then 1
1855
+ WHEN search_terms.source = 'city' then 1
1856
+ ELSE 0
1857
+ END AS match_score,
1858
+ employees.*
1859
+ FROM employees
1860
+ JOIN search_terms
1861
+ ON search_terms.findable_id = employees.id
1862
+ AND search_terms.findable_type = 'Employee'
1863
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1864
+ ) AS e1
1865
+ GROUP BY e1.id
1866
+ ORDER BY score DESC
1867
+
1868
+  (0.0ms) SAVEPOINT active_record_1
1869
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1870
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
1871
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1872
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1873
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1874
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1875
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1876
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1877
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
1878
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1879
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1880
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1881
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1882
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
1883
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1884
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1885
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
1886
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
1887
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
1888
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1889
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
1890
+ FROM dossiers
1891
+ JOIN search_terms
1892
+ ON search_terms.findable_id = dossiers.id
1893
+ AND search_terms.findable_type = 'Dossier'
1894
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
1895
+ GROUP BY dossiers.id
1896
+ ORDER BY hits DESC
1897
+
1898
+  (0.8ms) rollback transaction
1899
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1900
+  (0.1ms) begin transaction
1901
+ --------------------------------
1902
+ PlainSearchTest: test_by_example
1903
+ --------------------------------
1904
+  (0.0ms) SAVEPOINT active_record_1
1905
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
1906
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1907
+  (0.0ms) SAVEPOINT active_record_1
1908
+ SQL (0.2ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
1909
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1910
+  (0.0ms) SAVEPOINT active_record_1
1911
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
1912
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1913
+  (0.0ms) SAVEPOINT active_record_1
1914
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
1915
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1916
+  (0.0ms) SAVEPOINT active_record_1
1917
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
1918
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1919
+  (0.0ms) SAVEPOINT active_record_1
1920
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
1921
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1922
+  (0.0ms) SAVEPOINT active_record_1
1923
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
1924
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1925
+  (0.0ms) SAVEPOINT active_record_1
1926
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
1927
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1928
+  (0.0ms) SAVEPOINT active_record_1
1929
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
1930
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1931
+  (0.0ms) SAVEPOINT active_record_1
1932
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
1933
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1934
+  (0.0ms) SAVEPOINT active_record_1
1935
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
1936
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
1937
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
1938
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
1939
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
1940
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1941
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
1942
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
1943
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
1944
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
1945
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
1946
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
1947
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
1948
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
1949
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1950
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1951
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1952
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1953
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
1954
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1955
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
1956
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
1957
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
1958
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
1959
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
1960
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1961
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1962
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
1963
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
1964
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
1965
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
1966
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
1967
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
1968
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
1969
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
1970
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1971
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
1972
+ FROM (
1973
+ SELECT
1974
+ CASE
1975
+ WHEN search_terms.source = 'first_name' then 10
1976
+ WHEN search_terms.source = 'last_name' then 10
1977
+ WHEN search_terms.source = 'profession' then 5
1978
+ WHEN search_terms.source = 'address' then 1
1979
+ WHEN search_terms.source = 'zip_code' then 1
1980
+ WHEN search_terms.source = 'city' then 1
1981
+ ELSE 0
1982
+ END AS match_score,
1983
+ employees.*
1984
+ FROM employees
1985
+ JOIN search_terms
1986
+ ON search_terms.findable_id = employees.id
1987
+ AND search_terms.findable_type = 'Employee'
1988
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
1989
+ ) AS e1
1990
+ GROUP BY e1.id
1991
+ ORDER BY score DESC
1992
+
1993
+  (0.0ms) SAVEPOINT active_record_1
1994
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
1995
+ Dossier Load (0.1ms) SELECT "dossiers".* FROM "dossiers"
1996
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
1997
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
1998
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
1999
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2000
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2001
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2002
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2003
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2004
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2005
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2006
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2007
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2008
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2009
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2010
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2011
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2012
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2013
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2014
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2015
+ FROM dossiers
2016
+ JOIN search_terms
2017
+ ON search_terms.findable_id = dossiers.id
2018
+ AND search_terms.findable_type = 'Dossier'
2019
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2020
+ GROUP BY dossiers.id
2021
+ ORDER BY hits DESC
2022
+
2023
+  (1.5ms) rollback transaction
2024
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
2025
+  (0.1ms) begin transaction
2026
+ --------------------------------
2027
+ PlainSearchTest: test_by_example
2028
+ --------------------------------
2029
+  (0.0ms) SAVEPOINT active_record_1
2030
+ SQL (1.5ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2031
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2032
+  (0.0ms) SAVEPOINT active_record_1
2033
+ SQL (0.3ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2034
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2035
+  (0.0ms) SAVEPOINT active_record_1
2036
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2037
+  (0.2ms) RELEASE SAVEPOINT active_record_1
2038
+  (0.0ms) SAVEPOINT active_record_1
2039
+ SQL (0.0ms) INSERT INTO "employees" ("first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2040
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2041
+  (0.0ms) SAVEPOINT active_record_1
2042
+ SQL (0.3ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2043
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2044
+  (0.0ms) SAVEPOINT active_record_1
2045
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2046
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2047
+  (0.0ms) SAVEPOINT active_record_1
2048
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2049
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2050
+  (0.0ms) SAVEPOINT active_record_1
2051
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2052
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2053
+  (0.0ms) SAVEPOINT active_record_1
2054
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
2055
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2056
+  (0.0ms) SAVEPOINT active_record_1
2057
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
2058
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2059
+  (0.1ms) SAVEPOINT active_record_1
2060
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
2061
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
2062
+ SQL (0.5ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
2063
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
2064
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
2065
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2066
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
2067
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
2068
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
2069
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
2070
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
2071
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
2072
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
2073
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
2074
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2075
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2076
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2077
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2078
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
2079
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2080
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
2081
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
2082
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
2083
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
2084
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
2085
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2086
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2087
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
2088
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2089
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
2090
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2091
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2092
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2093
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2094
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2095
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2096
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
2097
+ FROM (
2098
+ SELECT
2099
+ CASE
2100
+ WHEN search_terms.source = 'first_name' then 10
2101
+ WHEN search_terms.source = 'last_name' then 10
2102
+ WHEN search_terms.source = 'profession' then 5
2103
+ WHEN search_terms.source = 'address' then 1
2104
+ WHEN search_terms.source = 'zip_code' then 1
2105
+ WHEN search_terms.source = 'city' then 1
2106
+ ELSE 0
2107
+ END AS match_score,
2108
+ employees.*
2109
+ FROM employees
2110
+ JOIN search_terms
2111
+ ON search_terms.findable_id = employees.id
2112
+ AND search_terms.findable_type = 'Employee'
2113
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
2114
+ ) AS e1
2115
+ GROUP BY e1.id
2116
+ ORDER BY score DESC
2117
+
2118
+  (0.0ms) SAVEPOINT active_record_1
2119
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
2120
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
2121
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2122
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2123
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2124
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2125
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2126
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2127
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2128
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2129
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2130
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2131
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2132
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2133
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2134
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2135
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2136
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2137
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2138
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2139
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2140
+ FROM dossiers
2141
+ JOIN search_terms
2142
+ ON search_terms.findable_id = dossiers.id
2143
+ AND search_terms.findable_type = 'Dossier'
2144
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2145
+ GROUP BY dossiers.id
2146
+ ORDER BY hits DESC
2147
+
2148
+  (0.7ms) rollback transaction
2149
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
2150
+  (0.1ms) begin transaction
2151
+ --------------------------------
2152
+ PlainSearchTest: test_by_example
2153
+ --------------------------------
2154
+  (0.0ms) SAVEPOINT active_record_1
2155
+ SQL (0.9ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
2156
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2157
+  (0.0ms) SAVEPOINT active_record_1
2158
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
2159
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2160
+  (0.0ms) SAVEPOINT active_record_1
2161
+ SQL (0.4ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2162
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2163
+  (0.3ms) SAVEPOINT active_record_1
2164
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2165
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2166
+  (0.0ms) SAVEPOINT active_record_1
2167
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2168
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2169
+  (0.0ms) SAVEPOINT active_record_1
2170
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2171
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2172
+  (0.0ms) SAVEPOINT active_record_1
2173
+ SQL (0.3ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2174
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2175
+  (0.0ms) SAVEPOINT active_record_1
2176
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2177
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2178
+  (0.0ms) SAVEPOINT active_record_1
2179
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2180
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2181
+  (0.0ms) SAVEPOINT active_record_1
2182
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2183
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2184
+  (0.0ms) SAVEPOINT active_record_1
2185
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
2186
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2187
+  (0.0ms) SAVEPOINT active_record_1
2188
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
2189
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2190
+  (0.0ms) SAVEPOINT active_record_1
2191
+ SQL (0.3ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
2192
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
2193
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2194
+ SQL (0.6ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2195
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
2196
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
2197
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
2198
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2199
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
2200
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
2201
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
2202
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
2203
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2204
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2205
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
2206
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
2207
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
2208
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
2209
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2210
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2211
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2212
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2213
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2214
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2215
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
2216
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2217
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
2218
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
2219
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
2220
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
2221
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
2222
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2223
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2224
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2225
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2226
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
2227
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2228
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
2229
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2230
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2231
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2232
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2233
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2234
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2235
+ Employee Load (0.3ms) SELECT SUM(e1.match_score) AS score, e1.*
2236
+ FROM (
2237
+ SELECT
2238
+ CASE
2239
+ WHEN search_terms.source = 'company_name' then 50
2240
+ WHEN search_terms.source = 'first_name' then 10
2241
+ WHEN search_terms.source = 'last_name' then 10
2242
+ WHEN search_terms.source = 'profession' then 5
2243
+ WHEN search_terms.source = 'address' then 1
2244
+ WHEN search_terms.source = 'zip_code' then 1
2245
+ WHEN search_terms.source = 'city' then 1
2246
+ ELSE 0
2247
+ END AS match_score,
2248
+ employees.*
2249
+ FROM employees
2250
+ JOIN search_terms
2251
+ ON search_terms.findable_id = employees.id
2252
+ AND search_terms.findable_type = 'Employee'
2253
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
2254
+ ) AS e1
2255
+ GROUP BY e1.id
2256
+ ORDER BY score DESC
2257
+
2258
+  (0.0ms) SAVEPOINT active_record_1
2259
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
2260
+ Dossier Load (0.1ms) SELECT "dossiers".* FROM "dossiers"
2261
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2262
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2263
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2264
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2265
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2266
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2267
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2268
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2269
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2270
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2271
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2272
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2273
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2274
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2275
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2276
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2277
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2278
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2279
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2280
+ FROM dossiers
2281
+ JOIN search_terms
2282
+ ON search_terms.findable_id = dossiers.id
2283
+ AND search_terms.findable_type = 'Dossier'
2284
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2285
+ GROUP BY dossiers.id
2286
+ ORDER BY hits DESC
2287
+
2288
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
2289
+ FROM (
2290
+ SELECT
2291
+ CASE
2292
+ WHEN search_terms.source = 'company_name' then 50
2293
+ WHEN search_terms.source = 'first_name' then 10
2294
+ WHEN search_terms.source = 'last_name' then 10
2295
+ WHEN search_terms.source = 'profession' then 5
2296
+ WHEN search_terms.source = 'address' then 1
2297
+ WHEN search_terms.source = 'zip_code' then 1
2298
+ WHEN search_terms.source = 'city' then 1
2299
+ ELSE 0
2300
+ END AS match_score,
2301
+ employees.*
2302
+ FROM employees
2303
+ JOIN search_terms
2304
+ ON search_terms.findable_id = employees.id
2305
+ AND search_terms.findable_type = 'Employee'
2306
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'ACME%'
2307
+ ) AS e1
2308
+ GROUP BY e1.id
2309
+ ORDER BY score DESC
2310
+ 
2311
+  (1.1ms) rollback transaction
2312
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2313
+  (0.1ms) begin transaction
2314
+ --------------------------------
2315
+ PlainSearchTest: test_by_example
2316
+ --------------------------------
2317
+  (0.0ms) SAVEPOINT active_record_1
2318
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
2319
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2320
+  (0.0ms) SAVEPOINT active_record_1
2321
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
2322
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2323
+  (0.0ms) SAVEPOINT active_record_1
2324
+ SQL (0.2ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2325
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2326
+  (0.1ms) SAVEPOINT active_record_1
2327
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2328
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2329
+  (0.1ms) SAVEPOINT active_record_1
2330
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2331
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2332
+  (0.0ms) SAVEPOINT active_record_1
2333
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2334
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2335
+  (0.0ms) SAVEPOINT active_record_1
2336
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2337
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2338
+  (0.0ms) SAVEPOINT active_record_1
2339
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2340
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2341
+  (0.0ms) SAVEPOINT active_record_1
2342
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2343
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2344
+  (0.0ms) SAVEPOINT active_record_1
2345
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2346
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2347
+  (0.0ms) SAVEPOINT active_record_1
2348
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
2349
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2350
+  (0.0ms) SAVEPOINT active_record_1
2351
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
2352
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2353
+  (0.0ms) SAVEPOINT active_record_1
2354
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
2355
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
2356
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2357
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2358
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
2359
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
2360
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
2361
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2362
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
2363
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
2364
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
2365
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
2366
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2367
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2368
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
2369
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
2370
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
2371
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
2372
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2373
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2374
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2375
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2376
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2377
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2378
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
2379
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2380
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
2381
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
2382
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
2383
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
2384
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
2385
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2386
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2387
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2388
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2389
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
2390
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2391
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
2392
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2393
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2394
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2395
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2396
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2397
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2398
+ Employee Load (0.3ms) SELECT SUM(e1.match_score) AS score, e1.*
2399
+ FROM (
2400
+ SELECT
2401
+ CASE
2402
+ WHEN search_terms.source = 'company_name' then 50
2403
+ WHEN search_terms.source = 'first_name' then 10
2404
+ WHEN search_terms.source = 'last_name' then 10
2405
+ WHEN search_terms.source = 'profession' then 5
2406
+ WHEN search_terms.source = 'address' then 1
2407
+ WHEN search_terms.source = 'zip_code' then 1
2408
+ WHEN search_terms.source = 'city' then 1
2409
+ ELSE 0
2410
+ END AS match_score,
2411
+ employees.*
2412
+ FROM employees
2413
+ JOIN search_terms
2414
+ ON search_terms.findable_id = employees.id
2415
+ AND search_terms.findable_type = 'Employee'
2416
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
2417
+ ) AS e1
2418
+ GROUP BY e1.id
2419
+ ORDER BY score DESC
2420
+
2421
+  (0.0ms) SAVEPOINT active_record_1
2422
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
2423
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
2424
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2425
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2426
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2427
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2428
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2429
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2430
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2431
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2432
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2433
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2434
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2435
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2436
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2437
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2438
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2439
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2440
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2441
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2442
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2443
+ FROM dossiers
2444
+ JOIN search_terms
2445
+ ON search_terms.findable_id = dossiers.id
2446
+ AND search_terms.findable_type = 'Dossier'
2447
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2448
+ GROUP BY dossiers.id
2449
+ ORDER BY hits DESC
2450
+
2451
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
2452
+ FROM (
2453
+ SELECT
2454
+ CASE
2455
+ WHEN search_terms.source = 'company_name' then 50
2456
+ WHEN search_terms.source = 'first_name' then 10
2457
+ WHEN search_terms.source = 'last_name' then 10
2458
+ WHEN search_terms.source = 'profession' then 5
2459
+ WHEN search_terms.source = 'address' then 1
2460
+ WHEN search_terms.source = 'zip_code' then 1
2461
+ WHEN search_terms.source = 'city' then 1
2462
+ ELSE 0
2463
+ END AS match_score,
2464
+ employees.*
2465
+ FROM employees
2466
+ JOIN search_terms
2467
+ ON search_terms.findable_id = employees.id
2468
+ AND search_terms.findable_type = 'Employee'
2469
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'ACME%'
2470
+ ) AS e1
2471
+ GROUP BY e1.id
2472
+ ORDER BY score DESC
2473
+ 
2474
+  (1.5ms) rollback transaction
2475
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2476
+  (0.1ms) begin transaction
2477
+ --------------------------------
2478
+ PlainSearchTest: test_by_example
2479
+ --------------------------------
2480
+  (0.0ms) SAVEPOINT active_record_1
2481
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
2482
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2483
+  (0.0ms) SAVEPOINT active_record_1
2484
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
2485
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2486
+  (0.0ms) SAVEPOINT active_record_1
2487
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2488
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2489
+  (0.0ms) SAVEPOINT active_record_1
2490
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2491
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2492
+  (0.0ms) SAVEPOINT active_record_1
2493
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2494
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2495
+  (0.0ms) SAVEPOINT active_record_1
2496
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2497
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2498
+  (0.0ms) SAVEPOINT active_record_1
2499
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2500
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2501
+  (0.0ms) SAVEPOINT active_record_1
2502
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2503
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2504
+  (0.0ms) SAVEPOINT active_record_1
2505
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2506
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2507
+  (0.0ms) SAVEPOINT active_record_1
2508
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2509
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2510
+  (0.0ms) SAVEPOINT active_record_1
2511
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
2512
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2513
+  (0.0ms) SAVEPOINT active_record_1
2514
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
2515
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2516
+  (0.0ms) SAVEPOINT active_record_1
2517
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
2518
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
2519
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2520
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2521
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
2522
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
2523
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
2524
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2525
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
2526
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
2527
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
2528
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
2529
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2530
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2531
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
2532
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
2533
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
2534
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
2535
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2536
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2537
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2538
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2539
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2540
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2541
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
2542
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2543
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
2544
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
2545
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
2546
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
2547
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
2548
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2549
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2550
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2551
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2552
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
2553
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2554
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
2555
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2556
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2557
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2558
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2559
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2560
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2561
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
2562
+ FROM (
2563
+ SELECT
2564
+ CASE
2565
+ WHEN search_terms.source = 'company_name' then 50
2566
+ WHEN search_terms.source = 'first_name' then 10
2567
+ WHEN search_terms.source = 'last_name' then 10
2568
+ WHEN search_terms.source = 'profession' then 5
2569
+ WHEN search_terms.source = 'address' then 1
2570
+ WHEN search_terms.source = 'zip_code' then 1
2571
+ WHEN search_terms.source = 'city' then 1
2572
+ ELSE 0
2573
+ END AS match_score,
2574
+ employees.*
2575
+ FROM employees
2576
+ JOIN search_terms
2577
+ ON search_terms.findable_id = employees.id
2578
+ AND search_terms.findable_type = 'Employee'
2579
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
2580
+ ) AS e1
2581
+ GROUP BY e1.id
2582
+ ORDER BY score DESC
2583
+
2584
+  (0.0ms) SAVEPOINT active_record_1
2585
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
2586
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
2587
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2588
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2589
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2590
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2591
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2592
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2593
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2594
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2595
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2596
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2597
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2598
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2599
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2600
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2601
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2602
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2603
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2604
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2605
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2606
+ FROM dossiers
2607
+ JOIN search_terms
2608
+ ON search_terms.findable_id = dossiers.id
2609
+ AND search_terms.findable_type = 'Dossier'
2610
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2611
+ GROUP BY dossiers.id
2612
+ ORDER BY hits DESC
2613
+
2614
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
2615
+ FROM (
2616
+ SELECT
2617
+ CASE
2618
+ WHEN search_terms.source = 'company_name' then 50
2619
+ WHEN search_terms.source = 'first_name' then 10
2620
+ WHEN search_terms.source = 'last_name' then 10
2621
+ WHEN search_terms.source = 'profession' then 5
2622
+ WHEN search_terms.source = 'address' then 1
2623
+ WHEN search_terms.source = 'zip_code' then 1
2624
+ WHEN search_terms.source = 'city' then 1
2625
+ ELSE 0
2626
+ END AS match_score,
2627
+ employees.*
2628
+ FROM employees
2629
+ JOIN search_terms
2630
+ ON search_terms.findable_id = employees.id
2631
+ AND search_terms.findable_type = 'Employee'
2632
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'ACME%'
2633
+ ) AS e1
2634
+ GROUP BY e1.id
2635
+ ORDER BY score DESC
2636
+ 
2637
+  (1.2ms) rollback transaction
2638
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2639
+  (0.1ms) begin transaction
2640
+ --------------------------------
2641
+ PlainSearchTest: test_by_example
2642
+ --------------------------------
2643
+  (0.0ms) SAVEPOINT active_record_1
2644
+ SQL (0.4ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
2645
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2646
+  (0.0ms) SAVEPOINT active_record_1
2647
+ SQL (0.2ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
2648
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2649
+  (0.0ms) SAVEPOINT active_record_1
2650
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2651
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2652
+  (0.0ms) SAVEPOINT active_record_1
2653
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2654
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2655
+  (0.0ms) SAVEPOINT active_record_1
2656
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2657
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2658
+  (0.0ms) SAVEPOINT active_record_1
2659
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2660
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2661
+  (0.0ms) SAVEPOINT active_record_1
2662
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2663
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2664
+  (0.0ms) SAVEPOINT active_record_1
2665
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2666
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2667
+  (0.0ms) SAVEPOINT active_record_1
2668
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2669
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2670
+  (0.0ms) SAVEPOINT active_record_1
2671
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2672
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2673
+  (0.0ms) SAVEPOINT active_record_1
2674
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
2675
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2676
+  (0.0ms) SAVEPOINT active_record_1
2677
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
2678
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2679
+  (0.0ms) SAVEPOINT active_record_1
2680
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
2681
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
2682
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2683
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2684
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
2685
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
2686
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
2687
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2688
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
2689
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
2690
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
2691
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
2692
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2693
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2694
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
2695
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
2696
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
2697
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
2698
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2699
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2700
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2701
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2702
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2703
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2704
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
2705
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2706
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
2707
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
2708
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
2709
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
2710
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
2711
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2712
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2713
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2714
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2715
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
2716
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2717
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
2718
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2719
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2720
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2721
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2722
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2723
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2724
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
2725
+ FROM (
2726
+ SELECT
2727
+ CASE
2728
+ WHEN search_terms.source = 'company_name' then 50
2729
+ WHEN search_terms.source = 'first_name' then 10
2730
+ WHEN search_terms.source = 'last_name' then 10
2731
+ WHEN search_terms.source = 'profession' then 5
2732
+ WHEN search_terms.source = 'address' then 1
2733
+ WHEN search_terms.source = 'zip_code' then 1
2734
+ WHEN search_terms.source = 'city' then 1
2735
+ ELSE 0
2736
+ END AS match_score,
2737
+ employees.*
2738
+ FROM employees
2739
+ JOIN search_terms
2740
+ ON search_terms.findable_id = employees.id
2741
+ AND search_terms.findable_type = 'Employee'
2742
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
2743
+ ) AS e1
2744
+ GROUP BY e1.id
2745
+ ORDER BY score DESC
2746
+
2747
+  (0.0ms) SAVEPOINT active_record_1
2748
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
2749
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
2750
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2751
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2752
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2753
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2754
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2755
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2756
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2757
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2758
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2759
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2760
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2761
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2762
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2763
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2764
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2765
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2766
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2767
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2768
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2769
+ FROM dossiers
2770
+ JOIN search_terms
2771
+ ON search_terms.findable_id = dossiers.id
2772
+ AND search_terms.findable_type = 'Dossier'
2773
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2774
+ GROUP BY dossiers.id
2775
+ ORDER BY hits DESC
2776
+
2777
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
2778
+ FROM (
2779
+ SELECT
2780
+ CASE
2781
+ WHEN search_terms.source = 'company_name' then 50
2782
+ WHEN search_terms.source = 'first_name' then 10
2783
+ WHEN search_terms.source = 'last_name' then 10
2784
+ WHEN search_terms.source = 'profession' then 5
2785
+ WHEN search_terms.source = 'address' then 1
2786
+ WHEN search_terms.source = 'zip_code' then 1
2787
+ WHEN search_terms.source = 'city' then 1
2788
+ ELSE 0
2789
+ END AS match_score,
2790
+ employees.*
2791
+ FROM employees
2792
+ JOIN search_terms
2793
+ ON search_terms.findable_id = employees.id
2794
+ AND search_terms.findable_type = 'Employee'
2795
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'initec%'
2796
+ ) AS e1
2797
+ GROUP BY e1.id
2798
+ ORDER BY score DESC
2799
+ 
2800
+  (1.1ms) rollback transaction
2801
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2802
+  (0.1ms) begin transaction
2803
+ --------------------------------
2804
+ PlainSearchTest: test_by_example
2805
+ --------------------------------
2806
+  (0.0ms) SAVEPOINT active_record_1
2807
+ SQL (0.4ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
2808
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2809
+  (0.0ms) SAVEPOINT active_record_1
2810
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
2811
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2812
+  (0.1ms) SAVEPOINT active_record_1
2813
+ SQL (0.2ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2814
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2815
+  (0.1ms) SAVEPOINT active_record_1
2816
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2817
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2818
+  (0.0ms) SAVEPOINT active_record_1
2819
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2820
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2821
+  (0.0ms) SAVEPOINT active_record_1
2822
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2823
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2824
+  (0.0ms) SAVEPOINT active_record_1
2825
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2826
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2827
+  (0.0ms) SAVEPOINT active_record_1
2828
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2829
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2830
+  (0.0ms) SAVEPOINT active_record_1
2831
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2832
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2833
+  (0.0ms) SAVEPOINT active_record_1
2834
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2835
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2836
+  (0.0ms) SAVEPOINT active_record_1
2837
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
2838
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2839
+  (0.0ms) SAVEPOINT active_record_1
2840
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
2841
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2842
+  (0.0ms) SAVEPOINT active_record_1
2843
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
2844
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
2845
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2846
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2847
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
2848
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
2849
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
2850
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2851
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
2852
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
2853
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
2854
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
2855
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
2856
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
2857
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
2858
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
2859
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
2860
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
2861
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2862
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2863
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2864
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2865
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2866
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2867
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
2868
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2869
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
2870
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
2871
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
2872
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
2873
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
2874
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2875
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2876
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
2877
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
2878
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
2879
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
2880
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
2881
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
2882
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
2883
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
2884
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
2885
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
2886
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2887
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
2888
+ FROM (
2889
+ SELECT
2890
+ CASE
2891
+ WHEN search_terms.source = 'company_name' then 50
2892
+ WHEN search_terms.source = 'first_name' then 10
2893
+ WHEN search_terms.source = 'last_name' then 10
2894
+ WHEN search_terms.source = 'profession' then 5
2895
+ WHEN search_terms.source = 'address' then 1
2896
+ WHEN search_terms.source = 'zip_code' then 1
2897
+ WHEN search_terms.source = 'city' then 1
2898
+ ELSE 0
2899
+ END AS match_score,
2900
+ employees.*
2901
+ FROM employees
2902
+ JOIN search_terms
2903
+ ON search_terms.findable_id = employees.id
2904
+ AND search_terms.findable_type = 'Employee'
2905
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
2906
+ ) AS e1
2907
+ GROUP BY e1.id
2908
+ ORDER BY score DESC
2909
+
2910
+  (0.0ms) SAVEPOINT active_record_1
2911
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
2912
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
2913
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2914
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2915
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2916
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
2917
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2918
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2919
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
2920
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
2921
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2922
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2923
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2924
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
2925
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
2926
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2927
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
2928
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
2929
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
2930
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2931
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
2932
+ FROM dossiers
2933
+ JOIN search_terms
2934
+ ON search_terms.findable_id = dossiers.id
2935
+ AND search_terms.findable_type = 'Dossier'
2936
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
2937
+ GROUP BY dossiers.id
2938
+ ORDER BY hits DESC
2939
+
2940
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
2941
+ FROM (
2942
+ SELECT
2943
+ CASE
2944
+ WHEN search_terms.source = 'company_name' then 50
2945
+ WHEN search_terms.source = 'first_name' then 10
2946
+ WHEN search_terms.source = 'last_name' then 10
2947
+ WHEN search_terms.source = 'profession' then 5
2948
+ WHEN search_terms.source = 'address' then 1
2949
+ WHEN search_terms.source = 'zip_code' then 1
2950
+ WHEN search_terms.source = 'city' then 1
2951
+ ELSE 0
2952
+ END AS match_score,
2953
+ employees.*
2954
+ FROM employees
2955
+ JOIN search_terms
2956
+ ON search_terms.findable_id = employees.id
2957
+ AND search_terms.findable_type = 'Employee'
2958
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'initec%'
2959
+ ) AS e1
2960
+ GROUP BY e1.id
2961
+ ORDER BY score DESC
2962
+ 
2963
+  (0.8ms) rollback transaction
2964
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2965
+  (0.1ms) begin transaction
2966
+ --------------------------------
2967
+ PlainSearchTest: test_by_example
2968
+ --------------------------------
2969
+  (0.2ms) SAVEPOINT active_record_1
2970
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
2971
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2972
+  (0.0ms) SAVEPOINT active_record_1
2973
+ SQL (0.2ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
2974
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2975
+  (0.0ms) SAVEPOINT active_record_1
2976
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
2977
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2978
+  (0.0ms) SAVEPOINT active_record_1
2979
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
2980
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2981
+  (0.0ms) SAVEPOINT active_record_1
2982
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
2983
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2984
+  (0.0ms) SAVEPOINT active_record_1
2985
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
2986
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2987
+  (0.3ms) SAVEPOINT active_record_1
2988
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
2989
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2990
+  (0.0ms) SAVEPOINT active_record_1
2991
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
2992
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2993
+  (0.3ms) SAVEPOINT active_record_1
2994
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
2995
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2996
+  (0.0ms) SAVEPOINT active_record_1
2997
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
2998
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2999
+  (0.0ms) SAVEPOINT active_record_1
3000
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
3001
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3002
+  (0.0ms) SAVEPOINT active_record_1
3003
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
3004
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3005
+  (0.0ms) SAVEPOINT active_record_1
3006
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
3007
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
3008
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3009
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3010
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
3011
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
3012
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
3013
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3014
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
3015
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
3016
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
3017
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
3018
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3019
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3020
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
3021
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
3022
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
3023
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
3024
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3025
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3026
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3027
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3028
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3029
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3030
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
3031
+ SQL (0.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3032
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
3033
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
3034
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
3035
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
3036
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
3037
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3038
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3039
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3040
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3041
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
3042
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3043
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
3044
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3045
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3046
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3047
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3048
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3049
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3050
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
3051
+ FROM (
3052
+ SELECT
3053
+ CASE
3054
+ WHEN search_terms.source = 'company_name' then 50
3055
+ WHEN search_terms.source = 'first_name' then 10
3056
+ WHEN search_terms.source = 'last_name' then 10
3057
+ WHEN search_terms.source = 'profession' then 5
3058
+ WHEN search_terms.source = 'address' then 1
3059
+ WHEN search_terms.source = 'zip_code' then 1
3060
+ WHEN search_terms.source = 'city' then 1
3061
+ ELSE 0
3062
+ END AS match_score,
3063
+ employees.*
3064
+ FROM employees
3065
+ JOIN search_terms
3066
+ ON search_terms.findable_id = employees.id
3067
+ AND search_terms.findable_type = 'Employee'
3068
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
3069
+ ) AS e1
3070
+ GROUP BY e1.id
3071
+ ORDER BY score DESC
3072
+
3073
+  (0.0ms) SAVEPOINT active_record_1
3074
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
3075
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
3076
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3077
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3078
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3079
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3080
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3081
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3082
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
3083
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3084
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3085
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3086
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3087
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
3088
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3089
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3090
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3091
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3092
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3093
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3094
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
3095
+ FROM dossiers
3096
+ JOIN search_terms
3097
+ ON search_terms.findable_id = dossiers.id
3098
+ AND search_terms.findable_type = 'Dossier'
3099
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
3100
+ GROUP BY dossiers.id
3101
+ ORDER BY hits DESC
3102
+
3103
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
3104
+ FROM (
3105
+ SELECT
3106
+ CASE
3107
+ WHEN search_terms.source = 'company_name' then 50
3108
+ WHEN search_terms.source = 'first_name' then 10
3109
+ WHEN search_terms.source = 'last_name' then 10
3110
+ WHEN search_terms.source = 'profession' then 5
3111
+ WHEN search_terms.source = 'address' then 1
3112
+ WHEN search_terms.source = 'zip_code' then 1
3113
+ WHEN search_terms.source = 'city' then 1
3114
+ ELSE 0
3115
+ END AS match_score,
3116
+ employees.*
3117
+ FROM employees
3118
+ JOIN search_terms
3119
+ ON search_terms.findable_id = employees.id
3120
+ AND search_terms.findable_type = 'Employee'
3121
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'initec%'
3122
+ ) AS e1
3123
+ GROUP BY e1.id
3124
+ ORDER BY score DESC
3125
+ 
3126
+  (1.3ms) rollback transaction
3127
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3128
+  (0.1ms) begin transaction
3129
+ --------------------------------
3130
+ PlainSearchTest: test_by_example
3131
+ --------------------------------
3132
+  (0.0ms) SAVEPOINT active_record_1
3133
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
3134
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3135
+  (0.0ms) SAVEPOINT active_record_1
3136
+ SQL (0.3ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
3137
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3138
+  (0.1ms) SAVEPOINT active_record_1
3139
+ SQL (0.2ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
3140
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3141
+  (0.0ms) SAVEPOINT active_record_1
3142
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
3143
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3144
+  (0.0ms) SAVEPOINT active_record_1
3145
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
3146
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3147
+  (0.0ms) SAVEPOINT active_record_1
3148
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
3149
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3150
+  (0.1ms) SAVEPOINT active_record_1
3151
+ SQL (0.1ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
3152
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3153
+  (0.0ms) SAVEPOINT active_record_1
3154
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
3155
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3156
+  (0.0ms) SAVEPOINT active_record_1
3157
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
3158
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3159
+  (0.0ms) SAVEPOINT active_record_1
3160
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
3161
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3162
+  (0.0ms) SAVEPOINT active_record_1
3163
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
3164
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3165
+  (0.1ms) SAVEPOINT active_record_1
3166
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
3167
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3168
+  (0.0ms) SAVEPOINT active_record_1
3169
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
3170
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
3171
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3172
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3173
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
3174
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
3175
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
3176
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3177
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
3178
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
3179
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
3180
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
3181
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3182
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3183
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
3184
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
3185
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
3186
+ SQL (8.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
3187
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3188
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3189
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3190
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3191
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3192
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3193
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
3194
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3195
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
3196
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
3197
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
3198
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
3199
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
3200
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3201
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3202
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3203
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3204
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
3205
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3206
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
3207
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3208
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3209
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3210
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3211
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3212
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3213
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
3214
+ FROM (
3215
+ SELECT
3216
+ CASE
3217
+ WHEN search_terms.source = 'company_name' then 50
3218
+ WHEN search_terms.source = 'first_name' then 10
3219
+ WHEN search_terms.source = 'last_name' then 10
3220
+ WHEN search_terms.source = 'profession' then 5
3221
+ WHEN search_terms.source = 'address' then 1
3222
+ WHEN search_terms.source = 'zip_code' then 1
3223
+ WHEN search_terms.source = 'city' then 1
3224
+ ELSE 0
3225
+ END AS match_score,
3226
+ employees.*
3227
+ FROM employees
3228
+ JOIN search_terms
3229
+ ON search_terms.findable_id = employees.id
3230
+ AND search_terms.findable_type = 'Employee'
3231
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
3232
+ ) AS e1
3233
+ GROUP BY e1.id
3234
+ ORDER BY score DESC
3235
+
3236
+  (0.1ms) SAVEPOINT active_record_1
3237
+ SQL (0.1ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
3238
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
3239
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3240
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3241
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3242
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3243
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3244
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3245
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
3246
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3247
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3248
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3249
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3250
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
3251
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3252
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3253
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3254
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3255
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3256
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3257
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
3258
+ FROM dossiers
3259
+ JOIN search_terms
3260
+ ON search_terms.findable_id = dossiers.id
3261
+ AND search_terms.findable_type = 'Dossier'
3262
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
3263
+ GROUP BY dossiers.id
3264
+ ORDER BY hits DESC
3265
+
3266
+ Employee Load (0.2ms)  SELECT SUM(e1.match_score) AS score, e1.*
3267
+ FROM (
3268
+ SELECT
3269
+ CASE
3270
+ WHEN search_terms.source = 'company_name' then 50
3271
+ WHEN search_terms.source = 'first_name' then 10
3272
+ WHEN search_terms.source = 'last_name' then 10
3273
+ WHEN search_terms.source = 'profession' then 5
3274
+ WHEN search_terms.source = 'address' then 1
3275
+ WHEN search_terms.source = 'zip_code' then 1
3276
+ WHEN search_terms.source = 'city' then 1
3277
+ ELSE 0
3278
+ END AS match_score,
3279
+ employees.*
3280
+ FROM employees
3281
+ JOIN search_terms
3282
+ ON search_terms.findable_id = employees.id
3283
+ AND search_terms.findable_type = 'Employee'
3284
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'initec%'
3285
+ ) AS e1
3286
+ GROUP BY e1.id
3287
+ ORDER BY score DESC
3288
+ 
3289
+  (0.8ms) rollback transaction
3290
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
3291
+  (0.3ms) begin transaction
3292
+ --------------------------------
3293
+ PlainSearchTest: test_by_example
3294
+ --------------------------------
3295
+  (0.0ms) SAVEPOINT active_record_1
3296
+ SQL (1.0ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
3297
+  (0.3ms) RELEASE SAVEPOINT active_record_1
3298
+  (0.0ms) SAVEPOINT active_record_1
3299
+ SQL (0.2ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
3300
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3301
+  (0.1ms) SAVEPOINT active_record_1
3302
+ SQL (0.4ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
3303
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3304
+  (0.3ms) SAVEPOINT active_record_1
3305
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
3306
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3307
+  (0.0ms) SAVEPOINT active_record_1
3308
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
3309
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3310
+  (0.0ms) SAVEPOINT active_record_1
3311
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
3312
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3313
+  (0.0ms) SAVEPOINT active_record_1
3314
+ SQL (0.3ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
3315
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3316
+  (0.0ms) SAVEPOINT active_record_1
3317
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
3318
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3319
+  (0.0ms) SAVEPOINT active_record_1
3320
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
3321
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3322
+  (0.0ms) SAVEPOINT active_record_1
3323
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
3324
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3325
+  (0.0ms) SAVEPOINT active_record_1
3326
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
3327
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3328
+  (0.0ms) SAVEPOINT active_record_1
3329
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
3330
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3331
+  (0.0ms) SAVEPOINT active_record_1
3332
+ SQL (0.3ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
3333
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
3334
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3335
+ SQL (0.5ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3336
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
3337
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
3338
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
3339
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3340
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
3341
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
3342
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
3343
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
3344
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3345
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3346
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
3347
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
3348
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
3349
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
3350
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3351
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3352
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3353
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3354
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3355
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3356
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
3357
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3358
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
3359
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
3360
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
3361
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
3362
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
3363
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3364
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3365
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3366
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3367
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
3368
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3369
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
3370
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3371
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3372
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3373
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3374
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3375
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3376
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
3377
+ FROM (
3378
+ SELECT
3379
+ CASE
3380
+ WHEN search_terms.source = 'company_name' then 50
3381
+ WHEN search_terms.source = 'first_name' then 10
3382
+ WHEN search_terms.source = 'last_name' then 10
3383
+ WHEN search_terms.source = 'profession' then 5
3384
+ WHEN search_terms.source = 'address' then 1
3385
+ WHEN search_terms.source = 'zip_code' then 1
3386
+ WHEN search_terms.source = 'city' then 1
3387
+ ELSE 0
3388
+ END AS match_score,
3389
+ employees.*
3390
+ FROM employees
3391
+ JOIN search_terms
3392
+ ON search_terms.findable_id = employees.id
3393
+ AND search_terms.findable_type = 'Employee'
3394
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
3395
+ ) AS e1
3396
+ GROUP BY e1.id
3397
+ ORDER BY score DESC
3398
+
3399
+  (0.0ms) SAVEPOINT active_record_1
3400
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
3401
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
3402
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3403
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3404
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3405
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3406
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3407
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3408
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
3409
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3410
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3411
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3412
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3413
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
3414
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3415
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3416
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3417
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3418
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3419
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3420
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
3421
+ FROM dossiers
3422
+ JOIN search_terms
3423
+ ON search_terms.findable_id = dossiers.id
3424
+ AND search_terms.findable_type = 'Dossier'
3425
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
3426
+ GROUP BY dossiers.id
3427
+ ORDER BY hits DESC
3428
+
3429
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
3430
+ FROM (
3431
+ SELECT
3432
+ CASE
3433
+ WHEN search_terms.source = 'company_name' then 50
3434
+ WHEN search_terms.source = 'first_name' then 10
3435
+ WHEN search_terms.source = 'last_name' then 10
3436
+ WHEN search_terms.source = 'profession' then 5
3437
+ WHEN search_terms.source = 'address' then 1
3438
+ WHEN search_terms.source = 'zip_code' then 1
3439
+ WHEN search_terms.source = 'city' then 1
3440
+ ELSE 0
3441
+ END AS match_score,
3442
+ employees.*
3443
+ FROM employees
3444
+ JOIN search_terms
3445
+ ON search_terms.findable_id = employees.id
3446
+ AND search_terms.findable_type = 'Employee'
3447
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'initec%'
3448
+ ) AS e1
3449
+ GROUP BY e1.id
3450
+ ORDER BY score DESC
3451
+ 
3452
+  (0.8ms) rollback transaction
3453
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
3454
+  (0.1ms) begin transaction
3455
+ --------------------------------
3456
+ PlainSearchTest: test_by_example
3457
+ --------------------------------
3458
+  (0.0ms) SAVEPOINT active_record_1
3459
+ SQL (0.9ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "ACME"]]
3460
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3461
+  (0.0ms) SAVEPOINT active_record_1
3462
+ SQL (0.2ms) INSERT INTO "companies" ("name") VALUES (?) [["name", "IniTec"]]
3463
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3464
+  (0.1ms) SAVEPOINT active_record_1
3465
+ SQL (0.3ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Andreas"], ["last_name", "Baumgart"], ["address", "Adalbertstr. 8"], ["zip_code", "10999"], ["city", "Berlin"], ["phone", "00491731234567"], ["email", "andreas@polycast.de"], ["profession", "Web Developer"]]
3466
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3467
+  (0.0ms) SAVEPOINT active_record_1
3468
+ SQL (0.1ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 1], ["first_name", "Oskar"], ["last_name", "Entenweich"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Visual Artist"]]
3469
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3470
+  (0.0ms) SAVEPOINT active_record_1
3471
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Sebastian"], ["last_name", "Sorglos"], ["address", "Auf dem Holzweg 1"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234501"], ["email", "oskar@polycast.de"], ["profession", "Administrator"]]
3472
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3473
+  (0.0ms) SAVEPOINT active_record_1
3474
+ SQL (0.0ms) INSERT INTO "employees" ("company_id", "first_name", "last_name", "address", "zip_code", "city", "phone", "email", "profession") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["company_id", 2], ["first_name", "Susi"], ["last_name", "Sorglos"], ["address", "Hauptstrasse 10"], ["zip_code", "33602"], ["city", "Bielefeld"], ["phone", "00491791234502"], ["email", "oskar@polycast.de"], ["profession", "Mobile Developer"]]
3475
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3476
+  (0.0ms) SAVEPOINT active_record_1
3477
+ SQL (0.3ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-cv.pdf"]]
3478
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3479
+  (0.0ms) SAVEPOINT active_record_1
3480
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "susi-portfolio.pdf"]]
3481
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3482
+  (0.0ms) SAVEPOINT active_record_1
3483
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "sebastian.pdf"]]
3484
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3485
+  (0.0ms) SAVEPOINT active_record_1
3486
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-cv.doc"]]
3487
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3488
+  (0.0ms) SAVEPOINT active_record_1
3489
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "andreas-cv.doc"]]
3490
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3491
+  (0.0ms) SAVEPOINT active_record_1
3492
+ SQL (0.0ms) INSERT INTO "dossiers" ("filename") VALUES (?) [["filename", "oskar-portfolio.doc"]]
3493
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3494
+  (0.0ms) SAVEPOINT active_record_1
3495
+ SQL (0.3ms) DELETE FROM "search_terms" WHERE (findable_type = 'Employee')
3496
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees"
3497
+ Company Load (0.1ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3498
+ SQL (2.2ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3499
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Andreas"], ["source", "first_name"]]
3500
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Baumgart"], ["source", "last_name"]]
3501
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Web"], ["source", "profession"]]
3502
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3503
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Adalbertstr"], ["source", "address"]]
3504
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "8"], ["source", "address"]]
3505
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "10999"], ["source", "zip_code"]]
3506
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Employee"], ["term", "Berlin"], ["source", "city"]]
3507
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 1]]
3508
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "ACME"], ["source", "company_name"]]
3509
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Oskar"], ["source", "first_name"]]
3510
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Entenweich"], ["source", "last_name"]]
3511
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Visual"], ["source", "profession"]]
3512
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Artist"], ["source", "profession"]]
3513
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3514
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3515
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3516
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3517
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3518
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3519
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sebastian"], ["source", "first_name"]]
3520
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3521
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Administrator"], ["source", "profession"]]
3522
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Auf"], ["source", "address"]]
3523
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "dem"], ["source", "address"]]
3524
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Holzweg"], ["source", "address"]]
3525
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "1"], ["source", "address"]]
3526
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3527
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3528
+ Company Load (0.0ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = ? LIMIT 1 [["id", 2]]
3529
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "IniTec"], ["source", "company_name"]]
3530
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Susi"], ["source", "first_name"]]
3531
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Sorglos"], ["source", "last_name"]]
3532
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Mobile"], ["source", "profession"]]
3533
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Developer"], ["source", "profession"]]
3534
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Hauptstrasse"], ["source", "address"]]
3535
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "10"], ["source", "address"]]
3536
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "33602"], ["source", "zip_code"]]
3537
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Employee"], ["term", "Bielefeld"], ["source", "city"]]
3538
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3539
+ Employee Load (0.2ms) SELECT SUM(e1.match_score) AS score, e1.*
3540
+ FROM (
3541
+ SELECT
3542
+ CASE
3543
+ WHEN search_terms.source = 'company_name' then 50
3544
+ WHEN search_terms.source = 'first_name' then 10
3545
+ WHEN search_terms.source = 'last_name' then 10
3546
+ WHEN search_terms.source = 'profession' then 5
3547
+ WHEN search_terms.source = 'address' then 1
3548
+ WHEN search_terms.source = 'zip_code' then 1
3549
+ WHEN search_terms.source = 'city' then 1
3550
+ ELSE 0
3551
+ END AS match_score,
3552
+ employees.*
3553
+ FROM employees
3554
+ JOIN search_terms
3555
+ ON search_terms.findable_id = employees.id
3556
+ AND search_terms.findable_type = 'Employee'
3557
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'sorglos%' OR search_terms.term LIKE '33602%' OR search_terms.term LIKE 'hauptstrasse%' OR search_terms.term LIKE 'developer%'
3558
+ ) AS e1
3559
+ GROUP BY e1.id
3560
+ ORDER BY score DESC
3561
+
3562
+  (0.0ms) SAVEPOINT active_record_1
3563
+ SQL (0.0ms) DELETE FROM "search_terms" WHERE (findable_type = 'Dossier')
3564
+ Dossier Load (0.0ms) SELECT "dossiers".* FROM "dossiers"
3565
+ SQL (0.1ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3566
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3567
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 1], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3568
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "susi"], ["source", "filename"]]
3569
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3570
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 2], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3571
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "sebastian"], ["source", "filename"]]
3572
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 3], ["findable_type", "Dossier"], ["term", "pdf"], ["source", "filename"]]
3573
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3574
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3575
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 4], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3576
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "andreas"], ["source", "filename"]]
3577
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "cv"], ["source", "filename"]]
3578
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 5], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3579
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "oskar"], ["source", "filename"]]
3580
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "portfolio"], ["source", "filename"]]
3581
+ SQL (0.0ms) INSERT INTO "search_terms" ("findable_id", "findable_type", "term", "source") VALUES (?, ?, ?, ?) [["findable_id", 6], ["findable_type", "Dossier"], ["term", "doc"], ["source", "filename"]]
3582
+  (0.0ms) RELEASE SAVEPOINT active_record_1
3583
+ Dossier Load (0.1ms) SELECT dossiers.*, COUNT(search_terms.id) as hits
3584
+ FROM dossiers
3585
+ JOIN search_terms
3586
+ ON search_terms.findable_id = dossiers.id
3587
+ AND search_terms.findable_type = 'Dossier'
3588
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'portfolio%' OR search_terms.term LIKE 'pdf%'
3589
+ GROUP BY dossiers.id
3590
+ ORDER BY hits DESC
3591
+
3592
+ Employee Load (0.1ms)  SELECT SUM(e1.match_score) AS score, e1.*
3593
+ FROM (
3594
+ SELECT
3595
+ CASE
3596
+ WHEN search_terms.source = 'company_name' then 50
3597
+ WHEN search_terms.source = 'first_name' then 10
3598
+ WHEN search_terms.source = 'last_name' then 10
3599
+ WHEN search_terms.source = 'profession' then 5
3600
+ WHEN search_terms.source = 'address' then 1
3601
+ WHEN search_terms.source = 'zip_code' then 1
3602
+ WHEN search_terms.source = 'city' then 1
3603
+ ELSE 0
3604
+ END AS match_score,
3605
+ employees.*
3606
+ FROM employees
3607
+ JOIN search_terms
3608
+ ON search_terms.findable_id = employees.id
3609
+ AND search_terms.findable_type = 'Employee'
3610
+ WHERE search_terms.term LIKE 'susi%' OR search_terms.term LIKE 'initec%'
3611
+ ) AS e1
3612
+ GROUP BY e1.id
3613
+ ORDER BY score DESC
3614
+ 
3615
+  (0.9ms) rollback transaction