(resp *elastic.SearchResult)
| 138 | } |
| 139 | |
| 140 | func (s *SearchEngine) warpResult(resp *elastic.SearchResult) ([]plugin.SearchResult, int64, error) { |
| 141 | res := make([]plugin.SearchResult, 0) |
| 142 | for _, hit := range resp.Hits.Hits { |
| 143 | docByte, err := hit.Source.MarshalJSON() |
| 144 | if err != nil { |
| 145 | log.Errorf("es unmarshal error: %v", err) |
| 146 | continue |
| 147 | } |
| 148 | |
| 149 | var content AnswerPostDoc |
| 150 | err = json.Unmarshal(docByte, &content) |
| 151 | if err != nil { |
| 152 | log.Errorf("es unmarshal error: %v", err) |
| 153 | continue |
| 154 | } |
| 155 | |
| 156 | res = append(res, plugin.SearchResult{ |
| 157 | ID: hit.Id, |
| 158 | Type: content.Type, |
| 159 | }) |
| 160 | } |
| 161 | log.Debugf("search result: %d", len(res)) |
| 162 | return res, resp.TotalHits(), nil |
| 163 | } |
| 164 | |
| 165 | func (s *SearchEngine) ConfigFields() []plugin.ConfigField { |
| 166 | return []plugin.ConfigField{ |
no outgoing calls
no test coverage detected