Skip to content

Instantly share code, notes, and snippets.

@kates
Created January 16, 2014 03:22
Show Gist options
  • Save kates/8449290 to your computer and use it in GitHub Desktop.
Save kates/8449290 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
define_index do
set_property enable_star: true
indexes :name
indexes :phone
indexes :address
end
def self.query(options)
return unless options[:q]
query = "@name (#{options[:q]}*) | @phone (#{options[:q]}*) | @address (#{options[:q]}*)"
search(query, match_mode: :extended2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment