-
-
Save jsonperl/14434f091d3860df5fb4fda52d94f04c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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