我有一个装满了上千份文件的桶。我如何搜索水桶?


当前回答

AWS发布了使用SQL: Amazon Athena https://aws.amazon.com/athena/查询S3桶的新服务

其他回答

考虑到你在AWS…我认为你会想要使用他们的CloudSearch工具。把你想要搜索的数据放到他们的服务中…让它指向S3密钥。

http://aws.amazon.com/cloudsearch/

(至少)有两个不同的用例可以描述为“搜索桶”:

Search for something inside every object stored at the bucket; this assumes a common format for all the objects in that bucket (say, text files), etc etc. For something like this, you're forced to do what Cody Caughlan just answered. The AWS S3 docs has example code showing how to do this with the AWS SDK for Java: Listing Keys Using the AWS SDK for Java (there you'll also find PHP and C# examples). List item Search for something in the object keys contained in that bucket; S3 does have partial support for this, in the form of allowing prefix exact matches + collapsing matches after a delimiter. This is explained in more detail at the AWS S3 Developer Guide. This allows, for example, to implement "folders" through using as object keys something like folder/subfolder/file.txt If you follow this convention, most of the S3 GUIs (such as the AWS Console) will show you a folder view of your bucket.

试试这个命令:

aws s3api list-objects --bucket your-bucket --prefix sub-dir-path --output text --query 'Contents[].{Key: Key}'

然后,您可以将其输送到grep中,以获得特定的文件类型,以便对它们做任何您想做的事情。

使用Amazon Athena查询S3桶。另外,加载数据到Amazon Elastic搜索。希望这能有所帮助。

这里要补充一点:现在已经3年了,但当你输入“如何搜索S3 Bucket”时,这篇文章是谷歌的顶部。

也许你正在寻找一些更复杂的东西,但如果你在这里试图弄清楚如何简单地通过标题找到一个对象(文件),这是疯狂的简单:

打开桶,选择右边的“none”,并开始输入文件名。

http://docs.aws.amazon.com/AmazonS3/latest/UG/ListingObjectsinaBucket.html