From 250fefd0d85ec29ee639331c8a5ca4413c444551 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 30 Jul 2024 09:27:52 +0200 Subject: [PATCH] search is debug nested object included --- dbs/mongo/mongo.go | 8 +------- models/resources/data/data_mongo_accessor.go | 3 ++- models/resources/datacenter/datacenter_mongo_accessor.go | 2 +- models/resources/processing/processing_mongo_accessor.go | 2 +- models/resources/storage/storage_mongo_accessor.go | 2 +- models/resources/workflow/workflow_mongo_accessor.go | 2 +- models/workflow/workflow_mongo_accessor.go | 2 +- models/workspace/workspace_mongo_accessor.go | 2 +- 8 files changed, 9 insertions(+), 14 deletions(-) diff --git a/dbs/mongo/mongo.go b/dbs/mongo/mongo.go index ce37b7e..37342ee 100644 --- a/dbs/mongo/mongo.go +++ b/dbs/mongo/mongo.go @@ -253,17 +253,11 @@ func (m *MongoDB) Search(search string, filter []string, collection_name string) if cursor, err := targetDBCollection.Find( MngoCtx, - bson.M{"$or": []bson.M{ - {"abstractresource.abstractobject.name": bson.M{"$regex": search, "$options": "i"}}, - {"abstractresource.description": bson.M{"$regex": search, "$options": "i"}}, - }}, + bson.M{"$or": list}, opts, ); err != nil { - fmt.Println(0, bson.M{"$or": list}) return nil, 404, err } else { - fmt.Println(cursor, bson.M{"$or": list}) - return cursor, 200, nil } } diff --git a/models/resources/data/data_mongo_accessor.go b/models/resources/data/data_mongo_accessor.go index a002206..771a07b 100644 --- a/models/resources/data/data_mongo_accessor.go +++ b/models/resources/data/data_mongo_accessor.go @@ -56,7 +56,8 @@ func (wfa DataMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) { func (wfa *DataMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name", "short_description", "description", "owner", "source_url"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractresource.abstractobject.name", "abstractresource.short_description", "abstractresource.description", "abstractresource.owner", "abstractresource.source_url"}, + wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err diff --git a/models/resources/datacenter/datacenter_mongo_accessor.go b/models/resources/datacenter/datacenter_mongo_accessor.go index 51d6582..0950acb 100644 --- a/models/resources/datacenter/datacenter_mongo_accessor.go +++ b/models/resources/datacenter/datacenter_mongo_accessor.go @@ -58,7 +58,7 @@ func (wfa DatacenterMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, erro func (wfa *DatacenterMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name", "short_description", "description", "owner", "source_url"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractresource.abstractobject.name", "abstractresource.short_description", "abstractresource.description", "abstractresource.owner", "abstractresource.source_url"}, wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err diff --git a/models/resources/processing/processing_mongo_accessor.go b/models/resources/processing/processing_mongo_accessor.go index d4b5de5..3d41b29 100644 --- a/models/resources/processing/processing_mongo_accessor.go +++ b/models/resources/processing/processing_mongo_accessor.go @@ -59,7 +59,7 @@ func (wfa ProcessingMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, erro func (wfa *ProcessingMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name", "short_description", "description", "owner", "source_url"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractresource.abstractobject.name", "abstractresource.short_description", "abstractresource.description", "abstractresource.owner", "abstractresource.source_url"}, wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err diff --git a/models/resources/storage/storage_mongo_accessor.go b/models/resources/storage/storage_mongo_accessor.go index f80c8f1..604e653 100644 --- a/models/resources/storage/storage_mongo_accessor.go +++ b/models/resources/storage/storage_mongo_accessor.go @@ -59,7 +59,7 @@ func (wfa StorageMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) func (wfa *StorageMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name", "short_description", "description", "owner", "source_url"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractresource.abstractobject.name", "abstractresource.short_description", "abstractresource.description", "abstractresource.owner", "abstractresource.source_url"}, wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err diff --git a/models/resources/workflow/workflow_mongo_accessor.go b/models/resources/workflow/workflow_mongo_accessor.go index a3a876c..271b10f 100644 --- a/models/resources/workflow/workflow_mongo_accessor.go +++ b/models/resources/workflow/workflow_mongo_accessor.go @@ -62,7 +62,7 @@ func (wfa WorkflowResourceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int func (wfa *WorkflowResourceMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name", "short_description", "description", "owner", "source_url"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractresource.abstractobject.name", "abstractresource.short_description", "abstractresource.description", "abstractresource.owner", "abstractresource.source_url"}, wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index 0abfc57..0a51011 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -157,7 +157,7 @@ func (wfa WorkflowMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) func (wfa *WorkflowMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractobject.name"}, wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err diff --git a/models/workspace/workspace_mongo_accessor.go b/models/workspace/workspace_mongo_accessor.go index aa813e1..c5685c6 100644 --- a/models/workspace/workspace_mongo_accessor.go +++ b/models/workspace/workspace_mongo_accessor.go @@ -122,7 +122,7 @@ func (wfa WorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error func (wfa *WorkspaceMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) { objs := []utils.ShallowDBObject{} - res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name"}, wfa.GetType()) + res_mongo, code, err := mongo.MONGOService.Search(word, []string{"abstractobject.name"}, wfa.GetType()) if err != nil { wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error()) return nil, code, err