Adds fuzzy string matching and prefix matching

This commit is contained in:
Albert Yi
2018-08-24 12:04:49 -07:00
parent 68c30961ac
commit 66e413b540
6 changed files with 245 additions and 37 deletions

View File

@@ -10,6 +10,7 @@ class TagsController < ApplicationController
def index
@tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
respond_with(@tags) do |format|
format.xml do
render :xml => @tags.to_xml(:root => "tags")
@@ -18,7 +19,13 @@ class TagsController < ApplicationController
end
def autocomplete
@tags = Tag.names_matches_with_aliases(params[:search][:name_matches])
if CurrentUser.is_builder?
# limit rollout
@tags = TagAutocomplete.search(params[:search][:name_matches])
else
@tags = Tag.names_matches_with_aliases(params[:search][:name_matches])
end
expires_in params[:expiry].to_i.days if params[:expiry]
respond_with(@tags) do |format|