Sha256: dfd8c0dab2c6b87dacc67ec12edc252cdcbbd8e1f6ec5a5c196ad3a639a35554
Contents?: true
Size: 776 Bytes
Versions: 4
Compression:
Stored size: 776 Bytes
Contents
module Enjoy::Search::Searchable extend ActiveSupport::Concern module ClassMethods def enjoy_search_fts_index(*opts) if Enjoy::Search.mongoid? opts = opts.extract_options! index( { name: "text" }.merge(opts[:fields]), { default_language: opts[:default_language] || "russian", weights: { name: 100 }.merge(opts[:weights]), name: opts[:name] } ) end end end included do scope :fts, -> (query) { ret = where({"$text": { "$search": query.to_s }}) ret.options[:fields] = {"score": { "$meta": "textScore" }} ret.options[:sort] = {"score": { "$meta": "textScore" }} ret } end end
Version data entries
4 entries across 4 versions & 1 rubygems