Skip to content

Commit

Permalink
imp
Browse files Browse the repository at this point in the history
Signed-off-by: Avraham Shalev <[email protected]>
  • Loading branch information
avrahams committed Apr 4, 2024
1 parent 4cacb4d commit 45089dd
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 3 deletions.
91 changes: 90 additions & 1 deletion db/mongo/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,96 @@ var collectionIndexes = map[string][]mongo.IndexModel{
{Key: "customers", Value: 1},
},
},
//TODO: index most used fields in owner and relatedObjects
{
Keys: bson.D{
{Key: "owner.name", Value: 1},
},
},
{
Keys: bson.D{
{Key: "owner.kind", Value: 1},
},
},
{
Keys: bson.D{
{Key: "owner.namespace", Value: 1},
},
},
{
Keys: bson.D{
{Key: "owner.cluster", Value: 1},
},
},
{
Keys: bson.D{
{Key: "owner.repoHash", Value: 1},
},
},
{
Keys: bson.D{
{Key: "owner.resourceID", Value: 1},
},
},
{
Keys: bson.D{
{Key: "owner.resourceHash", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.layerHash", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.controlID", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.baseScore", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.cveName", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.cveID", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.severity", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.severityScore", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.component", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.componentVersion", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.imageRepository", Value: 1},
},
},
{
Keys: bson.D{
{Key: "relatedObjects.imageRepository", Value: 1},
},
},
},
}

Expand Down
2 changes: 0 additions & 2 deletions handlers/v2ListRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ func uniqueValuesRequest2FindOptions(ctx *gin.Context, request armotypes.UniqueV
return findOptions, nil
}

// TODO - use schema info to query arrays with $elemMatch
// and to map ambiguous fields types (e.g time.time vs string)
func buildInnerFilter(ctx *gin.Context, innerFilter map[string]string) (*db.FilterBuilder, error) {
filterBuilder := db.NewFilterBuilder()
schemaInfo := db.GetSchemaFromContext(ctx)
Expand Down

0 comments on commit 45089dd

Please sign in to comment.