Commit 51817f55f213bc49b64411d851080f393d1e6abc
1 parent
5a819cd9
Exists in
master
and in
19 other branches
Use env var for setup [skip ci]
Showing
1 changed file
with
13 additions
and
9 deletions
Show diff stats
benchmark/search.rb
... | ... | @@ -19,19 +19,23 @@ class Product < ActiveRecord::Base |
19 | 19 | end |
20 | 20 | end |
21 | 21 | |
22 | -# total_docs = 1000000 | |
22 | +if ENV["SETUP"] | |
23 | + total_docs = 1000000 | |
23 | 24 | |
24 | -# ActiveRecord::Migration.create_table :products, force: :cascade do |t| | |
25 | -# t.string :name | |
26 | -# t.string :color | |
27 | -# t.integer :store_id | |
28 | -# end | |
25 | + ActiveRecord::Migration.create_table :products, force: :cascade do |t| | |
26 | + t.string :name | |
27 | + t.string :color | |
28 | + t.integer :store_id | |
29 | + end | |
30 | + | |
31 | + Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] } | |
29 | 32 | |
30 | -# Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] } | |
33 | + puts "Imported" | |
31 | 34 | |
32 | -# puts "Imported" | |
35 | + Product.reindex | |
33 | 36 | |
34 | -# Product.reindex | |
37 | + puts "Reindexed" | |
38 | +end | |
35 | 39 | |
36 | 40 | query = Product.search("product", fields: [:name], where: {color: "red", store_id: 5}, limit: 10000, load: false, execute: false) |
37 | 41 | ... | ... |