[英]How to sort and filter using metadata in Google Cloud Storage?
I am using metadata on blobs in a Google Cloud Storage bucket to store important information regarding a specific blob.我在 Google Cloud Storage 存储桶中使用 blob 的元数据来存储有关特定 blob 的重要信息。 I would like to use the Sort and filter
functionality that is available from the Cloud Storage UI a bit more extensively.我想更广泛地使用 Cloud Storage UI 提供的Sort and filter
功能。 The available filter properties seem to be:可用的过滤器属性似乎是:
But no filter property for metadata is available.但是没有元数据的过滤器属性可用。 However, some functionality to filter on metadata seems to be present.但是,似乎存在一些过滤元数据的功能。 For example.例如。 If there are two files present, one with the metadata key-value pair special_key: true
and the other one no metadata tag and I filter (in the UI) with Sort and filter
, special_key
then the only file that remains is the one with the tag.如果存在两个文件,一个具有元数据键值对special_key: true
,另一个没有元数据标记,我使用Sort and filter
过滤(在 UI 中), special_key
那么唯一剩下的文件就是带有标签。
However, I cannot filter more specifically on the label, for example special_key = true
to only show the blobs with a certain value of a metadata key.但是,我无法在 label 上进行更具体的过滤,例如special_key = true
以仅显示具有特定元数据键值的 blob。 Is there a way to do this?有没有办法做到这一点? A similar question has been asked here , but the best answer solves this by using the SDK and not the UI itself, which is the preferred solution. 此处提出了类似的问题,但最佳答案是使用 SDK 而不是 UI 本身来解决此问题,这是首选解决方案。
As mentioned in the document :如 文档中所述:
In the Cloud Console list of objects for a bucket, you can filter the objects you see by specifying a prefix in the Filter by object or folder name prefix... text box, located above the list of objects.在存储桶的 Cloud Console 对象列表中,您可以通过在位于对象列表上方的过滤条件 object 或文件夹名称前缀... 文本框中指定前缀来过滤您看到的对象。 This filter displays objects beginning with the specified prefix.此过滤器显示以指定前缀开头的对象。 The prefix only filters objects in your current bucket view: it does not select objects contained in folders.前缀仅过滤当前存储桶视图中的对象:它不过滤文件夹中包含的 select 个对象。
For your case, you can do this answer_1 and answer_2 :对于您的情况,您可以执行此answer_1和answer_2 :
You would need to list all the objects and then filter at the client side.您需要列出所有对象,然后在客户端进行过滤。 Another option, if it's possible to rename your objects, would be to construct your object names such that the metadata values on which you want to filter are built into the beginning of the object names.如果可以重命名您的对象,另一种选择是构造您的 object 名称,以便将要过滤的元数据值内置到 object 名称的开头。 You could then use a prefix filter on the listing request.然后,您可以对列表请求使用前缀过滤器。
There is one Public issue tracker created on the similar issue, you can take a look .有一个针对类似问题创建的公共问题跟踪器,您可以看一看。
For more information, you can refer to the documentation .更多信息,您可以参考文档。
how about: GCS --> Cloud Functions --> some database;怎么样:GCS --> Cloud Functions --> 一些数据库; use the db index for filtering/searching使用数据库索引进行过滤/搜索
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.