From 51817f55f213bc49b64411d851080f393d1e6abc Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 2 Mar 2018 19:42:37 -0800 Subject: [PATCH] Use env var for setup [skip ci] --- benchmark/search.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/benchmark/search.rb b/benchmark/search.rb index 0971a22..b355861 100644 --- a/benchmark/search.rb +++ b/benchmark/search.rb @@ -19,19 +19,23 @@ class Product < ActiveRecord::Base end end -# total_docs = 1000000 +if ENV["SETUP"] + total_docs = 1000000 -# ActiveRecord::Migration.create_table :products, force: :cascade do |t| -# t.string :name -# t.string :color -# t.integer :store_id -# end + ActiveRecord::Migration.create_table :products, force: :cascade do |t| + t.string :name + t.string :color + t.integer :store_id + end + + Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] } -# Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] } + puts "Imported" -# puts "Imported" + Product.reindex -# Product.reindex + puts "Reindexed" +end query = Product.search("product", fields: [:name], where: {color: "red", store_id: 5}, limit: 10000, load: false, execute: false) -- libgit2 0.21.0