search is debug nested object included

This commit is contained in:
mr 2024-07-30 09:27:52 +02:00
parent 6ac855394b
commit 250fefd0d8
8 changed files with 9 additions and 14 deletions

View File

@ -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
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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