add solr search(still have some problem)
This commit is contained in:
parent
481f04c07b
commit
52e393a2df
|
@ -22,7 +22,9 @@ class Panel::Dictionary::FrontEnd::DictionaryVocabsController < OrbitWidgetContr
|
||||||
if params[:search_query].empty?
|
if params[:search_query].empty?
|
||||||
@vocabs = DictionaryVocab.all
|
@vocabs = DictionaryVocab.all
|
||||||
else
|
else
|
||||||
@vocabs = DictionaryVocab.search(params[:search_query])
|
@vocabs = DictionaryVocab.solr_search do
|
||||||
|
fulltext params[:search_query]
|
||||||
|
end.results
|
||||||
end
|
end
|
||||||
# @item = Page.find(params[:page_id])
|
# @item = Page.find(params[:page_id])
|
||||||
# @title = @item.title
|
# @title = @item.title
|
||||||
|
|
|
@ -4,7 +4,7 @@ class DictionaryVocab
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
include Mongoid::Sortable
|
include Mongoid::Sortable
|
||||||
|
include Sunspot::Mongo
|
||||||
BelongsToCategory = :dictionary_vocab_category
|
BelongsToCategory = :dictionary_vocab_category
|
||||||
include OrbitCoreLib::BelongsToCategoryMayDisable
|
include OrbitCoreLib::BelongsToCategoryMayDisable
|
||||||
|
|
||||||
|
@ -24,20 +24,12 @@ class DictionaryVocab
|
||||||
# field :is_hidden, :type => Boolean, :default => false
|
# field :is_hidden, :type => Boolean, :default => false
|
||||||
|
|
||||||
scope :can_display, where(is_hidden: false)
|
scope :can_display, where(is_hidden: false)
|
||||||
|
|
||||||
belongs_to :dictionary_vocab_category
|
searchable do
|
||||||
|
text :word
|
||||||
def self.search(search)
|
|
||||||
if search
|
|
||||||
@search = DictionaryVocab.solr_search do
|
|
||||||
fulltext(search)
|
|
||||||
with(:frontend_search, true)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
scoped
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
belongs_to :dictionary_vocab_category
|
||||||
# has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
|
# has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
|
||||||
|
|
||||||
# accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
|
# accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span8 offset1">
|
<div class="span8">
|
||||||
<table class="table" align ="center">
|
<table class="table" align ="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td ><%= t :category, :scope => :dictionary %></td>
|
<td ><%= t :category, :scope => :dictionary %></td>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<%= form_tag panel_dictionary_front_end_dictionary_vocabs_path, method: :get do %>
|
<%= form_tag panel_dictionary_front_end_dictionary_vocabs_path, method: :get do %>
|
||||||
<%= hidden_field_tag :category_id, params[:category_id] %>
|
|
||||||
<p>
|
<p>
|
||||||
<%= text_field_tag :search_query, params[:search_query],{ value: (params[:search_query].blank? ? '' : params[:search_query]), placeholder: t("dictionary.widget.search") }%>
|
<%= text_field_tag :search_query, params[:search_query],{ value: (params[:search_query].blank? ? '' : params[:search_query]), placeholder: t("dictionary.widget.search") }%>
|
||||||
<%= submit_tag t("dictionary.widget.search"), name: nil %>
|
<%= submit_tag t("dictionary.widget.search"), name: nil %>
|
||||||
|
|
Loading…
Reference in New Issue