Search Images using custom metadata attribute with multiple values for same key
Hello Team,
Problem: We are using images metadata attributes to query cloudinary using search api. Now we have added multiple values for same custom metadata attributes which are separated by space since same image can be part of multiple usecase.
For e.g.
Image1
Custom Metadata
Source System (Key): Src1 Src2 Src3 (Value)
When we are passing single value in API query it is not returning any result. For e.g. in given usecase when I pass Key = Source System and Value = Src1. No result, But when I pass "Src1 Src2 Src3" I get response with image detail.
My Ask:
1. How to perform like search based on only one value
2. What is the recommendation to capture more than one value for same custom key
-
Hi Roopesh,
We announced our new structure metadata that might work the best for you to organize the data and then search for it in the future.
You can read about it here:
Please note that if you want to try this feature we will need to set it on your account. you can do it by open a support request at support@cloudinary.com with your cloud name.
Hope that helps,
0 -
Hi Shirly,
My ask is still not answered in this document. I need to know if cloudinary recommend to capture multiple values for same key ? and how to perform search using one value from multiple values
0 -
It depends on your use-case. You can use `set` or `enum` as your type of metadata (we will need to turn on structure metadata for you).
If you would like please open a support ticket to discuss your use case.
0 -
Hi Shirly,
My request is more of reading data from another application which is integrated with cloudinary. . Please refer to below scenario. For each image we have metadata attributes like Brand, Product-Family. Now for each metadata we are capturing multiple values for e.g. Brand = ABC;BCD;CB as refer in screenshot. Now I am using search api using context and I am trying to pass brand value = CB to get search result. But I am not get any response. I have to pass entire string of "ABC;BCD;CB" to get response.
So I wanted to understand if we cannot capture multiple values for same metadata like Brand shown in this example and how I should perform search so that I can get output with Image details.
0 -
Hi Roopesh,
You should be able to search for a supplier name using your example above, with a search expression like this:
context.Brand=BCDHowever, if the search term is very short you may not get good results, so BCD in this case may be too short.
tried it in my own account with some longer values and it worked correctly when I had Brand set to "abcdef;bobco;brandco" - a search API expression of "context.Brand:bobco" finds the file correctly.Another possible option is to store the metadata fields you need to search most often as tags, for example, adding three tags like "Brand:ABC" "Brand:BCD", "Brand"CB"; this would give you other benefits like being able to request a JSON list of all images for brand ABC: https://cloudinary.com/documentation/advanced_url_delivery_options#client_side_resources
Please let me know if that helps,Regards,
Stephen0 -
Hi Stephen,
The recommended solution worked, But I am facing another issue which is more related to incremental.
Scenario: Business users are updating custom metadata every day for the images. But via API we are not seeing any changes on created_at or updated_at dates. Can you please let me know if there is any way to identify if there is change in the image record when someone updates metadata via API
Thanks for help
0 -
Hi Roopesh,
You can add notification URL in your upload setting. Then you can see the response at your notification URL. For example:
{"notification_type":"resource_context_changed","source":"api","resources":{"my-public-id:{"added":[{"name":"key1","value":"mykey1"}],"removed":[],"updated":[]}}}
If you are using the API then you can pass the notification_url param and that should send the response to the webhook.
Thanks,
Aditi
0 -
Hi Aditi,
Not sure you understand my problem statement, Because your response doesn't relate to my problem. Let me explain by problem
Scenario: I as business users.. decided to update custom metadata attribute to update image metadata … I make changes and close the image..
Now when i try to check changes .. I am not able to track update via api .. which attribute I shud consider for identifying change in metadata .. via API
0 -
Hi Roopesh,
The `created_at` and `updated_at` values refer to the asset itself and aren't updated when the metadata is changed.
If you'd like know when a business user changes some of the metadata, the option Aditi recommended is the best method for this, because we'll send your notification URL a request indicating the image which was changed and which values were added immediately after the change is made, so you don't need to poll or query the API periodically to see what has changed.
For example, using the same file I used before if I configure a notification URL for my account and then add another value to the 'Brand' key in the image's context, my notification URL receives a request with this data:
{ "notification_type": "resource_context_changed", "source": "api", "resources": { "kitten_wide": { "added": [], "removed": [], "updated": [ { "name": "Brand", "value": "ABCDEF;GHIJKL", "previous_value": "ABCDEF" } ], "resource_type": "image", "type": "upload" } } }
And when I add a tag, the request looks like this:
{ "notification_type": "resource_context_changed", "source": "api", "resources": { "kitten_wide": { "added": [], "removed": [], "updated": [ { "name": "Brand", "value": "ABCDEF;GHIJKL", "previous_value": "ABCDEF" } ], "resource_type": "image", "type": "upload" } } }
This would notify you immediately about all changes, so you don't need to query via the API
Regards,
Stephen
0 -
Thanks Stephen,
Quick question:
Is custom metadata part of upload response which is sent to notification URL ?
Also where in console we can add notification url. Can you please provide some steps to make this change ?
Thanks,
Roopeh
0 -
Hi Roopeh,
Yes, the custom metadata is part of the upload response.
You can add the notification URL here: https://cloudinary.com/console/settings/upload or if you are using an upload preset then there is an option to add the notification_url in the preset.
Regards,
Aditi
0
Post is closed for comments.
Comments
11 comments