pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 469 forks source link

Provide a search method under a unique name #1264

Closed JasonBarnabe closed 1 month ago

JasonBarnabe commented 1 month ago

Related to #1241.

If you have TS and something else both trying to define ActiveRecord::Base.search, it's unclear which implementation you will end up with. If TS also defined something like ActiveRecord::Base.ts_search, then this could be used to target TS specifically.

A monkeypatch to accomplish this:

# To disambiguate #search (ES vs TS).
module DisambiguousThinkingSphinx
  extend ActiveSupport::Concern

  module ClassMethods
    def ts_search(query = nil, options = {})
      merge_search ThinkingSphinx.search, query, options
    end
  end
end
ActiveRecord::Base.include DisambiguousThinkingSphinx
pat commented 1 month ago

Ended up implementing this in #1265, and is part of 5.6.0 which has just been released :)