全站搜索

This commit is contained in:
lizanle 2015-11-27 15:17:17 +08:00
parent 3d9f632105
commit e710f443c2
4 changed files with 15 additions and 7 deletions

View File

@ -119,8 +119,9 @@ class Attachment < ActiveRecord::Base
}
},
sort:{
downloads: {order:"desc"},
_score:{order:"desc"}
_score:{order:"desc"},
downloads: {order:"desc"}
},
highlight: {
pre_tags: ['<span class="c_red">'],

View File

@ -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: ['<span class="c_red">'],
@ -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

View File

@ -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: {

View File

@ -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