From e710f443c2dfc61d8711b872363cca32dab80417 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 15:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 5 +++-- app/models/course.rb | 12 ++++++++++-- app/models/project.rb | 4 ++-- app/models/user.rb | 1 - 4 files changed, 15 insertions(+), 7 deletions(-) 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