diff --git a/app/models/course.rb b/app/models/course.rb index 71cd74633..e73257033 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -16,7 +16,7 @@ class Course < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, 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 diff --git a/app/models/project.rb b/app/models/project.rb index 92e6a4d0b..0453f1164 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -39,7 +39,7 @@ class Project < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, 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 @@ -195,12 +195,12 @@ class Project < ActiveRecord::Base query: query, type:"most_fields", operator: "and", - fields: ['name','description^0.5'] + fields: ['name'] } }, sort: { - updated_on:{order: "desc" }, - _score:{order: "desc" } + _score:{order: "desc" }, + updated_on:{order: "desc" } }, highlight: { pre_tags: [''], @@ -1217,13 +1217,19 @@ class Project < ActiveRecord::Base def create_project_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.index_document + end end def update_project_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.update_document + end end def delete_project_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.delete_document + end end diff --git a/app/models/user.rb b/app/models/user.rb index fc18313a0..15578f6db 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,7 +35,8 @@ class User < Principal indexes :login, analyzer: 'smartcn',index_options: 'offsets' indexes :firstname, 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 @@ -278,8 +279,8 @@ class User < Principal } }, sort:{ - last_login_on: {order:"desc"}, - _score:{order:"desc"} + _score:{order:"desc"}, + last_login_on: {order:"desc"} }, highlight: { pre_tags: [''], diff --git a/config/application.rb b/config/application.rb index 14793fcac..5f9c9d67e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -73,7 +73,13 @@ module RedmineApp end 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 if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))