TP-5555 | search addition

This commit is contained in:
varnit goyal
2025-01-09 16:06:55 +05:30
parent 3bd26de65a
commit 5a32a8acee
4 changed files with 21 additions and 6 deletions

View File

@@ -81,8 +81,6 @@ func (el *ElasticSearchClient) SearchDocuments(searchRequest string, fields []st
}
}
log.Printf("%s", aggregations)
return results, aggregations, res.Hits.Total.Value, nil
}

View File

@@ -15,7 +15,6 @@ import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"gorm.io/gorm"
"net/http"
)
@@ -120,7 +119,7 @@ func (exceptionService *ExceptionService) CatchErrors(c *gin.Context) {
//ensure we are processing a valid payload
if len(lines) <= 2 {
exceptionService.logger.Error("payload is not valid", zap.Strings("payload", lines))
//exceptionService.logger.Error("payload is not valid", zap.Strings("payload", lines))
c.JSON(http.StatusOK, gin.H{"status": "payload is not valid"})
return
}
@@ -145,6 +144,7 @@ func (exceptionService *ExceptionService) CatchErrors(c *gin.Context) {
err := exceptionService.kafkaProducer.PublishEvent(errorItem, exceptionService.kafkaConfig.Topic, "", nil, encoder.JsonEncoderInstance)
if err != nil {
exceptionService.logger.Error("Error publishing exception to Kafka: " + err.Error())
fmt.Println("Failed to push error to kafka")
}
}

14
service/package.json Normal file
View File

@@ -0,0 +1,14 @@
{
"name": "service",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/navi-ppl/cybertron.git"
},
"private": true
}

View File

@@ -74,11 +74,14 @@ func (s *SearchService) GetSearchResults(c *gin.Context) {
size_query := utils.CreateSizeQuery(int64(sizeInNumber))
term_query := utils.CreateTermSubQuery("project_id", projectId)
multiMatchQuery := utils.CreateMultiMatchQuery(search_key, "error", "title", "extra.metadata")
multiMatchQuery := utils.CreateMultiMatchQuery(search_key, "error", "title", "extra.metadata.agentId",
"extra.metadata.external_customer_id",
"extra.metadata.deviceId",
"extra.metadata.web_session_id", "extra.metadata.id")
should_query := utils.CreateMustQuery(term_query, multiMatchQuery)
boolQuery := utils.CreateBoolQuery(should_query)
search_query := utils.CreateSearchQuery(boolQuery)
source_query := utils.CreateSourceQuery("error")
source_query := utils.CreateSourceQuery("error", "error_hash", "created_at")
finalQuery := utils.CreateEsQuery(source_query, search_query, size_query)
fields := []string{"error", "significant_stack", "title"}
var res, _, total, err = s.elasticSearchClient.SearchDocuments(finalQuery, fields)