Skip to content

Instantly share code, notes, and snippets.

@jbwl
Forked from ankane/searchkick_repro.rb
Created September 12, 2018 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbwl/75078616bce6e2e153feaf1e221e4925 to your computer and use it in GitHub Desktop.
Save jbwl/75078616bce6e2e153feaf1e221e4925 to your computer and use it in GitHub Desktop.
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "activerecord"
gem "sqlite3"
gem "searchkick", git: "https://github.com/ankane/searchkick.git"
end
require "active_record"
puts "Searchkick version: #{Searchkick::VERSION}"
puts "Elasticsearch version: #{Searchkick.server_version}"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Migration.create_table :products do |t|
t.string :name
end
class Product < ActiveRecord::Base
searchkick
end
Product.reindex
Product.create!(name: "Test")
Product.search_index.refresh
p Product.search("test", fields: [:name]).response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment