我有一个rails应用程序需要独立搜索两个不同的集合,但两者都在一个solr实例中编入索引。但是,当我尝试在一个集合中搜索时,当我到达我想要显示的项目时,它会重新路由到另一个集合中的相同ID。我应该如何调整我的routes.rb来解决这个问题?
以下是代码:
Rails.application.routes.draw do
get 'biofile/search'
get 'masterfile/search'
mount Blacklight::Engine => '/'
Blacklight::Marc.add_routes(self)
root to: "catalog#index"
concern :searchable, Blacklight::Routes::Searchable.new
resource :catalog, only: [:index], as: 'catalog', path: '/', controller: 'catalog' do
concerns :searchable
end
resource :masterfile, only: [:search], as: 'masterfile', path: '/masterfile', controller: 'masterfile' do
concerns :searchable
end
resource :biofile, only: [:search], as: 'biofile', path: '/biofile', controller: 'biofile' do
concerns :searchable
end
devise_for :users
concern :exportable, Blacklight::Routes::Exportable.new
resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog' do
concerns :exportable
end
resources :solr_documents, only: [:show], path: 'masterfile', controller: 'masterfile' do
concerns :exportable
end
resources :solr_documents, only: [:show], path: 'biofile', controller: 'biofile' do
concerns :exportable
end
resources :bookmarks do
concerns :exportable
collection do
delete 'clear'
end
end
get '/catalog/masterfile/', to: 'masterfile#search', as: 'masterfile'
get '/catalog/biofile/', to: 'biofile#search', as: 'biofile'
get '*path' => redirect('/')
end
答案 0 :(得分:0)
在rails 5.x中使用rails routes
或在rails 4中使用rake routes
来查看新路由的列表,您可以看到网址将带有2个可以传递给您的应用程序的ID。
# nested routes for groups
resources :groups do
resources :memberships
end
答案 1 :(得分:0)
我认为您需要通过配置或monkeypatch覆盖此方法https://github.com/projectblacklight/blacklight/blob/9f676994f437f7664cfc2b5c4dffe4382a6d14d3/lib/blacklight/search_state.rb#L48,以根据solr文档中的某些信息采取不同的行为