Fix discovery search result

Fix aggregation filter(left side menu filter) matches, added minimum match criteria to match exact string match for search result.
This commit is contained in:
Vivek Patel
2023-02-14 14:45:25 +05:30
parent 4a3001bc5d
commit 51a6515d11
2 changed files with 12 additions and 7 deletions
+8 -6
View File
@@ -87,7 +87,7 @@ func conv(sr *esSearchResponse, aggregation *esSearchResponse, noHits bool, modu
if aggregation != nil {
aggsRes = aggregation.Aggregations
}
//for _, bucket := range aggsRes.Resource.Buckets {
// for _, bucket := range aggsRes.Resource.Buckets {
// bucketName := getResourceName(bucket.Key)
// if bucketName == "User" {
// continue
@@ -152,7 +152,7 @@ func conv(sr *esSearchResponse, aggregation *esSearchResponse, noHits bool, modu
// }
// }
// }
//}
// }
nsAggregation := cdAggregation{
Name: "Namespace",
@@ -171,10 +171,12 @@ func conv(sr *esSearchResponse, aggregation *esSearchResponse, noHits bool, modu
if nsHandleMap != nil {
name = nsHandleMap[resourceName].Name
}
nsTotalHits[resourceName] = cdAggregationHits{
Name: name,
Label: resourceName,
Hits: bucket.DocCount,
if len(name) > 0 {
nsTotalHits[resourceName] = cdAggregationHits{
Name: name,
Label: resourceName,
Hits: bucket.DocCount,
}
}
}
}
+4 -1
View File
@@ -57,7 +57,8 @@ type (
Query string `json:"query"`
Type string `json:"type"`
// Operator string `json:"operator"`
Fields []string `json:"fields"`
Fields []string `json:"fields"`
MinimumShouldMatch string `json:"minimum_should_match"`
} `json:"multi_match"`
}
@@ -288,6 +289,7 @@ func esSearch(ctx context.Context, log *zap.Logger, esc *elasticsearch.Client, p
for _, mAggs := range p.moduleAggs {
mm.Wrap.Query = mAggs
mm.Wrap.Type = "cross_fields"
mm.Wrap.MinimumShouldMatch = "100%"
mm.Wrap.Fields = []string{"module.name"}
// query.Query.Bool.Must = append(query.Query.Bool.Must, mm)
// query.Query.DisMax.Queries = append(query.Query.DisMax.Queries, mm)
@@ -307,6 +309,7 @@ func esSearch(ctx context.Context, log *zap.Logger, esc *elasticsearch.Client, p
for _, nAggs := range p.namespaceAggs {
mm.Wrap.Query = nAggs
mm.Wrap.Type = "cross_fields"
mm.Wrap.MinimumShouldMatch = "100%"
mm.Wrap.Fields = []string{"namespace.name"}
// query.Query.Bool.Must = append(query.Query.Bool.Must, mm)
// query.Query.DisMax.Queries = append(query.Query.DisMax.Queries, mm)