diff --git a/model/notification.go b/model/notification.go index 49b14f28..74c759d3 100644 --- a/model/notification.go +++ b/model/notification.go @@ -33,7 +33,7 @@ type Notification struct { Type NotificationType `json:"type,omitempty" elastic_mapping:"type:{type:keyword,fields:{text: {type: text}}}"` MessageType MessageType `json:"message_type,omitempty" elastic_mapping:"message_type:{type:keyword,fields:{text: {type: text}}}"` Status NotificationStatus `json:"status,omitempty" elastic_mapping:"status: { type: keyword }"` - Title string `json:"title,omitempty" elastic_mapping:"title: { type: keyword }"` - Body string `json:"body,omitempty" elastic_mapping:"body: { type: keyword }"` + Title string `json:"title,omitempty" elastic_mapping:"title: { type: text }"` + Body string `json:"body,omitempty" elastic_mapping:"body: { type: text }"` Link string `json:"link,omitempty" elastic_mapping:"link: { type: keyword }"` } diff --git a/plugin/api/notification/notification.go b/plugin/api/notification/notification.go index 9e011969..074d005f 100644 --- a/plugin/api/notification/notification.go +++ b/plugin/api/notification/notification.go @@ -15,10 +15,11 @@ import ( ) type SearchNotificationsRequest struct { - From int `json:"from"` - Size int `json:"size"` - Status []model.NotificationStatus `json:"status"` - Types []model.NotificationType `json:"types"` + From int `json:"from"` + Size int `json:"size"` + Keyword string `json:"keyword"` + Status []model.NotificationStatus `json:"status"` + Types []model.NotificationType `json:"types"` } func (h *NotificationAPI) searchNotifications(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { @@ -55,6 +56,9 @@ func (h *NotificationAPI) searchNotifications(w http.ResponseWriter, req *http.R if len(reqData.Types) > 0 { musts = append(musts, util.MapStr{"terms": util.MapStr{"type": reqData.Types}}) } + if len(reqData.Keyword) > 0 { + musts = append(musts, util.MapStr{"query_string": util.MapStr{"default_field": "*", "query": reqData.Keyword}}) + } var ( queryDSL = util.MapStr{