全站搜索
This commit is contained in:
parent
dcd441a9db
commit
ee47187a61
|
@ -16,7 +16,7 @@ class Course < ActiveRecord::Base
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets',type:"date"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Project < ActiveRecord::Base
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets', type:'date'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -195,12 +195,12 @@ class Project < ActiveRecord::Base
|
||||||
query: query,
|
query: query,
|
||||||
type:"most_fields",
|
type:"most_fields",
|
||||||
operator: "and",
|
operator: "and",
|
||||||
fields: ['name','description^0.5']
|
fields: ['name']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sort: {
|
sort: {
|
||||||
updated_on:{order: "desc" },
|
_score:{order: "desc" },
|
||||||
_score:{order: "desc" }
|
updated_on:{order: "desc" }
|
||||||
},
|
},
|
||||||
highlight: {
|
highlight: {
|
||||||
pre_tags: ['<span class="c_red">'],
|
pre_tags: ['<span class="c_red">'],
|
||||||
|
@ -1217,13 +1217,19 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
|
|
||||||
def create_project_ealasticsearch_index
|
def create_project_ealasticsearch_index
|
||||||
|
if self.is_public == 1
|
||||||
self.__elasticsearch__.index_document
|
self.__elasticsearch__.index_document
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def update_project_ealasticsearch_index
|
def update_project_ealasticsearch_index
|
||||||
|
if self.is_public == 1
|
||||||
self.__elasticsearch__.update_document
|
self.__elasticsearch__.update_document
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def delete_project_ealasticsearch_index
|
def delete_project_ealasticsearch_index
|
||||||
|
if self.is_public == 1
|
||||||
self.__elasticsearch__.delete_document
|
self.__elasticsearch__.delete_document
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ class User < Principal
|
||||||
indexes :login, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :login, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :firstname, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :firstname, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :lastname, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :lastname, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets',type: 'date'
|
||||||
|
indexes :id, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -278,8 +279,8 @@ class User < Principal
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sort:{
|
sort:{
|
||||||
last_login_on: {order:"desc"},
|
_score:{order:"desc"},
|
||||||
_score:{order:"desc"}
|
last_login_on: {order:"desc"}
|
||||||
},
|
},
|
||||||
highlight: {
|
highlight: {
|
||||||
pre_tags: ['<span class="c_red">'],
|
pre_tags: ['<span class="c_red">'],
|
||||||
|
|
|
@ -73,7 +73,13 @@ module RedmineApp
|
||||||
end
|
end
|
||||||
|
|
||||||
config.after_initialize do
|
config.after_initialize do
|
||||||
Elasticsearch::Client.new hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: true,log:true
|
if RbConfig::CONFIG['target_os'] == 'mswin32'
|
||||||
|
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true
|
||||||
|
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`)
|
||||||
|
Elasticsearch::Client.new hosts: ['192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true
|
||||||
|
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`)
|
||||||
|
Elasticsearch::Client.new hosts: ['192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||||||
|
|
Loading…
Reference in New Issue