Reputation: 1041
Is there any way to use wildcard after a word and before a word as mentioned below..
User.search "*" + "admi"+"*"
or any other solution to solve such problems using SearchKick gem.
Upvotes: 1
Views: 1169
Reputation: 21
Hope it's not too late.
You want the keyword to be appeared in the middle of the text, right? You should use Partial Matches as your search option.
For example, in model User:
class User < ActiveRecord::Base
searchkick text_middle: [ :name ]
end
Searching:
User.search("admi", fields: [{name: :text_middle}]).each do |user|
# Do something with user
end
If the search result is empty, try User.reindex
before a search.
Upvotes: 2