Search API : chaining items together
Hi there,
Hopefully someone can help me as I can't seem to make sense of the results with this.
Let's say this is a public_id of mine :
/review/abc/test/myimage.jpg
If I have the expression : resource_type:image AND folder:review
I get no results. Even though there are results in review. The documentation implies to me that using the colon should match any part of the path.
If I have the expression : resource_type:image AND folder:review/*
That returns items in the review folder, great.
But say I then want to add some further filters:
resource_type:image AND folder:review/* AND public_id:test
now returns nothing. I've tried various combinations with wildcards and not.
Basically given these 2 images :
/review/abc/test/myimage1.jpg
/review/abc/test2/myimage2.jpg
I want to be able to say something like
resource_type:image AND public_id:review/* AND public_id:abc AND public_id:test
So it only brings back myimage1. I can't do review/abc/test because abc could appear in a different location in the folder structure.
Hopefully that makes sense.
-
Official comment
Hi,
Currently we do not support search of subfolders via the API. Search of subfolders can be done via the main search box in Cloudinary's Media Library UI.
We have added this feature request to our Roadmap and will update this thread with any progress.
-
You can try our search API. For example:
cloudinary.v2.search
.expression('resource_type:image AND folder:review/* AND public_id:review/sample/dog*')
.sort_by('public_id','desc')
.max_results(30)
.execute().then(result=>console.log(result));0 -
Hi Shirly, given your example, say I don't know what subdirectory dog is in, all I know is its in review/ somewhere. How would you structure that ?
because I've tried
resource_type:image AND folder:review/* AND public_id:*dog*
resource_type:image AND folder:review/* AND public_id:review/*dog*
Neither seem to work - or they disregard the folder part.
0 -
Hi ,
Here is a sample code :
resource_type:image AND folder=review/* AND filename:dog
Hope that helps
0 -
Hi there. Thanks for the feedback. However still struggling. I want to be able to do partial searches on public_id and folders.
This doesn't seem possible.
if I have a file path like /animal/mammal/dog/alife.jpg . I just want to do a search where the folder or public id contains the word dog. I don't know path beforehand.
folder:dog does not work public_id:dog does not work, folder:*dog* does not work public_id:*dog* does not work.
According to the docs `folder:sample // any path that contains sample` this does not seem to be true. It seems to be any path that starts with sample.
1
Post is closed for comments.
Comments
5 comments