package service import ( "cybertron/internal/client/elastic" "cybertron/pkg/log" "github.com/elastic/go-elasticsearch/v8/typedapi/types" "github.com/gin-gonic/gin" "net/http" ) type SearchService struct { logger *log.Logger elasticSearchClient *elastic.ElasticSearchClient } func NewSearchService(logger *log.Logger, elasticSearchClient *elastic.ElasticSearchClient) *SearchService { return &SearchService{ logger: logger, elasticSearchClient: elasticSearchClient, } } func (s *SearchService) Search(c *gin.Context) { } func (s *SearchService) GetErrorDetails(c *gin.Context) { documentId := c.Query("document_id") response, _ := s.elasticSearchClient.GetDocument(documentId) c.JSON(http.StatusOK, response) } func (s *SearchService) GetErrorList(c *gin.Context) { //todo pagination and aggregation of errors projectId := c.Query("project_id") println(projectId) query := &types.Query{ Term: map[string]types.TermQuery{ "project_id": { Value: projectId, }, }, } fields := []string{"error", "significant_stack", "title"} var response, _ = s.elasticSearchClient.SearchDocuments(query, fields) c.JSON(http.StatusOK, response) }