MCPcopy Create free account
hub / github.com/apache/answer-plugins / warpResult

Method warpResult

search-elasticsearch/es.go:140–163  ·  view source on GitHub ↗
(resp *elastic.SearchResult)

Source from the content-addressed store, hash-verified

138}
139
140func (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
165func (s *SearchEngine) ConfigFields() []plugin.ConfigField {
166 return []plugin.ConfigField{

Callers 3

SearchContentsMethod · 0.95
SearchQuestionsMethod · 0.95
SearchAnswersMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected