From 226d4b2ac8888646271b9e9e83a513cd6e62d620 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 19 Jun 2018 05:46:29 -0400 Subject: 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 --- app/post.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/post.go') diff --git a/app/post.go b/app/post.go index 4f4c6f65c..e24018995 100644 --- a/app/post.go +++ b/app/post.go @@ -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 } } -- cgit v1.2.3-1-g7c22