MCPcopy Index your code
hub / github.com/apache/answer-plugins / SearchAnswers

Method SearchAnswers

search-elasticsearch/es.go:102–119  ·  view source on GitHub ↗
(
	ctx context.Context, cond *plugin.SearchBasicCond)

Source from the content-addressed store, hash-verified

100}
101
102func (s *SearchEngine) SearchAnswers(
103 ctx context.Context, cond *plugin.SearchBasicCond) (
104 res []plugin.SearchResult, total int64, err error) {
105 if s.Operator == nil {
106 return nil, 0, fmt.Errorf("es client not init")
107 }
108 query := s.buildQuery(cond)
109 query.Must(elastic.NewTermQuery("type", "answer"))
110 resp, err := s.Operator.QueryDoc(ctx, s.getIndexName(),
111 query, s.buildSort(cond), s.buildCols(), cond.Page, cond.PageSize)
112 if err != nil {
113 return nil, 0, fmt.Errorf("es query error: %w", err)
114 }
115 if resp == nil {
116 return nil, 0, nil
117 }
118 return s.warpResult(resp)
119}
120
121func (s *SearchEngine) UpdateContent(ctx context.Context, content *plugin.SearchContent) error {
122 if s.Operator == nil {

Callers

nothing calls this directly

Calls 6

buildQueryMethod · 0.95
getIndexNameMethod · 0.95
buildSortMethod · 0.95
buildColsMethod · 0.95
warpResultMethod · 0.95
QueryDocMethod · 0.80

Tested by

no test coverage detected