sunspot install
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -108,3 +108,6 @@ gem 'kaminari'
|
||||
gem 'bootstrap-kaminari-views', :git=>'git://github.com/matenia/bootstrap-kaminari-views.git'
|
||||
#gem 'will_paginate', :git=>'git://github.com/mislav/will_paginate.git'
|
||||
#gem 'bootstrap-will_paginate'
|
||||
|
||||
gem 'sunspot_rails'
|
||||
gem 'sunspot_solr'
|
||||
|
||||
@@ -32,12 +32,17 @@ class HomeController < ApplicationController
|
||||
def search
|
||||
|
||||
unless params['query'].nil? || params['query'].empty?
|
||||
if can?(:showintern, Neuigkeit)
|
||||
@neuigkeiten=Neuigkeit.search(params['query'])
|
||||
else
|
||||
@neuigkeiten =Neuigkeit.search(params['query']).public
|
||||
@results = Sunspot.search Neuigkeit, Fetprofile do
|
||||
fulltext params['query']
|
||||
end
|
||||
@fetprofiles = Fetprofile.search(params['query'])
|
||||
@neuigkeiten=[];
|
||||
if can?(:showintern, Neuigkeit)
|
||||
#@neuigkeiten=Neuigkeit.search(params['query'])
|
||||
else
|
||||
# @neuigkeiten =Neuigkeit.search(params['query']).public
|
||||
end
|
||||
# @fetprofiles = Fetprofile.search(params['query'])
|
||||
@fetprofiles=[]
|
||||
if can?(:showintern, Neuigkeit)
|
||||
@themen=Thema.search(params['query'])
|
||||
else
|
||||
|
||||
@@ -26,7 +26,7 @@ class Fetprofile < ActiveRecord::Base
|
||||
validate :validate_birthday
|
||||
GESCHLECHT={0=>"gendered", 1=>"maennlich", 2=>"weiblich"}
|
||||
has_many :users
|
||||
scope :search, ->(query) {where("nachname like ? or vorname like ? or short like ?", "%#{query}%", "%#{query}%", "%#{query}%")}
|
||||
# scope :search, ->(query) {where("nachname like ? or vorname like ? or short like ?", "%#{query}%", "%#{query}%", "%#{query}%")}
|
||||
|
||||
accepts_nested_attributes_for :memberships, :reject_if=>lambda{|a| a[:typ].blank?|| a[:start].blank? ||a[:gremium_id].blank?}, :allow_destroy=>true
|
||||
has_many :nlinks, as: :link
|
||||
@@ -64,4 +64,9 @@ end
|
||||
nil
|
||||
end
|
||||
end
|
||||
searchable do
|
||||
text :fetmailalias, :short, :fetmail
|
||||
text :vorname, :nachname, :boost=>2.0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
scope :public, ->{includes(:rubrik).where("rubriken.public"=>true)}
|
||||
scope :intern, ->{includes(:rubrik).where("rubriken.public"=>false)}
|
||||
|
||||
scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
|
||||
# scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
|
||||
LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile", "Gremium"]
|
||||
accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?}
|
||||
before_validation :sanitize
|
||||
@@ -83,4 +83,8 @@ class Neuigkeit < ActiveRecord::Base
|
||||
calentry.object=self
|
||||
end
|
||||
end
|
||||
searchable do
|
||||
text :text, :datum
|
||||
text :title, :boost=>3.0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
|
||||
<% unless @results.nil? %>
|
||||
<%= @results.results.each do |res| %>
|
||||
<%= render res %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% unless @neuigkeiten.empty? %>
|
||||
<h2>Neuigkeiten</h2>
|
||||
<% end %>
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="searchresults">
|
||||
<%= render :partial=>"home/search_results" %>
|
||||
|
||||
23
config/sunspot.yml
Normal file
23
config/sunspot.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
production:
|
||||
solr:
|
||||
hostname: localhost
|
||||
port: 8983
|
||||
log_level: WARNING
|
||||
path: /solr/production
|
||||
# read_timeout: 2
|
||||
# open_timeout: 0.5
|
||||
|
||||
development:
|
||||
solr:
|
||||
hostname: localhost
|
||||
port: 8982
|
||||
log_level: INFO
|
||||
path: /solr/development
|
||||
|
||||
test:
|
||||
solr:
|
||||
hostname: localhost
|
||||
port: 8981
|
||||
log_level: WARNING
|
||||
path: /solr/test
|
||||
|
||||
Reference in New Issue
Block a user