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:
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user