diff --git a/app/models/attachment.rb b/app/models/attachment.rb index dea4e404e..ebabbf944 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -119,8 +119,9 @@ class Attachment < ActiveRecord::Base } }, sort:{ - downloads: {order:"desc"}, - _score:{order:"desc"} + _score:{order:"desc"}, + downloads: {order:"desc"} + }, highlight: { pre_tags: [''], diff --git a/app/models/course.rb b/app/models/course.rb index 8f7c990ab..0bd14d38b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -122,8 +122,9 @@ class Course < ActiveRecord::Base } }, sort: { - updated_at:{order:"desc"}, - _score:{order: "desc" } + _score:{order: "desc" }, + updated_at:{order:"desc"} + }, highlight: { pre_tags: [''], @@ -393,13 +394,20 @@ class Course < ActiveRecord::Base # __elasticsearch__.delete_document # end def create_course_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.index_document + end end def update_course_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.update_document + end end def delete_course_ealasticsearch_index + + if self.is_public == 1 self.__elasticsearch__.delete_document + end end end diff --git a/app/models/project.rb b/app/models/project.rb index 034873596..847c536da 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -194,8 +194,8 @@ class Project < ActiveRecord::Base multi_match: { query: query, type:"most_fields", - operator: "and", - fields: ['name'] + operator: "or", + fields: ['name','description^0.5'] } }, sort: { diff --git a/app/models/user.rb b/app/models/user.rb index bf2bca6db..ced747af8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,7 +36,6 @@ class User < Principal indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' indexes :lastname, 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