MM-6992 Added highlighting to elasticsearch results (#8861)

* MM-6992 Added highlighting to elasticsearch results

* Added a unique type for post search matches

* Fixed Elasticsearch matches not being sent through API
Этот коммит содержится в:
Harrison Healey
2018-06-19 05:46:29 -04:00
коммит произвёл Carlos Tadeu Panato Junior
родитель 6d8140337e
Коммит 226d4b2ac8
6 изменённых файлов: 65 добавлений и 8 удалений

Просмотреть файл

@@ -621,7 +621,7 @@ func (a *App) DeletePostFiles(post *model.Post) {
}
}
func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bool) (*model.PostList, *model.AppError) {
func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bool) (*model.PostSearchResults, *model.AppError) {
paramsList := model.ParseSearchParams(terms)
esInterface := a.Elasticsearch
@@ -656,7 +656,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
// If the processed search params are empty, return empty search results.
if len(finalParamsList) == 0 {
return model.NewPostList(), nil
return model.MakePostSearchResults(model.NewPostList(), nil), nil
}
// We only allow the user to search in channels they are a member of.
@@ -666,7 +666,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
return nil, err
}
postIds, err := a.Elasticsearch.SearchPosts(userChannels, finalParamsList)
postIds, matches, err := a.Elasticsearch.SearchPosts(userChannels, finalParamsList)
if err != nil {
return nil, err
}
@@ -684,7 +684,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
}
}
return postList, nil
return model.MakePostSearchResults(postList, matches), nil
} else {
if !*a.Config().ServiceSettings.EnablePostSearch {
return nil, model.NewAppError("SearchPostsInTeam", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v userId=%v", teamId, userId), http.StatusNotImplemented)
@@ -712,7 +712,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
posts.SortByCreateAt()
return posts, nil
return model.MakePostSearchResults(posts, nil), nil
}
}