ユーザーが入力したテキストに基づいて solr 検索を実行しようとしています。まず、入力されたテキストがストアなのか、ブランドなのか、カテゴリなのかを確認する必要があります。その条件を確認した後、solr 検索を使用して MainNavigationUrls テーブルにある対応する riesults を表示したいと思います。これがコントローラーのアクションです。どの店に入っても問題なく動作しており、適切な結果が得られます。ただし、storesearch が nill であることが判明した場合、ブランド ループには入りません。2 番目のケースを実行しない理由を説明してください。
def search_all
@storesearch=Site.search do
fulltext params[:text]
with(:multibrand,1)
end
if(@storesearch.nil?)
@brandsearch=Brand.search do
fulltext params[:text]
end
if(@brandssearch.nil?)
@itemcategorysearch=MainCategory.search do
fulltext params[:text]
end
@itemcategorysearch.results.each do |result|
@itemcategorysearch1=MainNavigationUrl.search do
with :main_categoty_id, result.id
with :department_id, params[:deptid].to_i
paginate :page=>params[:page], :per_page=>45
end
end
else
@brandsearch.results.each do |result|
@brandsearch1=MainNavigationUrl.search do
with :brand_id, result.id
with :department_id, params[:deptid].to_i
paginate :page=>params[:page], :per_page=>45
end
end
else
@storesearch.results.each do |result|
@storesearch1=MainNavigationUrl.search do
with :site_id, result.id
with :department_id, params[:deptid].to_i
paginate :page=>params[:page], :per_page=>45
end
end
end
end