{
"repo": [
{
"book": 47,
"version": 1,
"bookName": "Book1",
"chapters": [
{
"chapterId": 1,
"chapterContents": [
{
"line": 1,
"Text": "1. The first text of chapter 1 book 1"
},
{
"line": 2,
"Text": "2. The second text of chapter 1 book 1"
}
]
},
{
"chapterId": 2,
"chapterContents": [
{
"line": 1,
"Text": "1. The first text of chapter 2 book 1"
}
]
}
]
}
]
}
這是在 Amazon S3 中存盤為 JSON 檔案的資料模型的格式。有很多書,有很多章節和文本內容。要求是在所有書籍中搜索特定文本并列出找到該文本的行、章、書籍和版本。如何對嵌套陣列 JSON 檔案進行 S3 查詢?
uj5u.com熱心網友回復:
您可以使用Amazon Athena從 S3 查詢嵌套的 JSON 資料。
應該可以在 json 中搜索值。你可以在這里找到一個例子:
WITH dataset AS (
SELECT * FROM (VALUES
(JSON '{"name": "Bob Smith", "org": "legal", "projects": ["project1"]}'),
(JSON '{"name": "Susan Smith", "org": "engineering", "projects": ["project1", "project2", "project3"]}'),
(JSON '{"name": "Jane Smith", "org": "finance", "projects": ["project1", "project2"]}')
) AS t (users)
)
SELECT json_extract_scalar(users, '$.name') AS user
FROM dataset
WHERE json_array_contains(json_extract(users, '$.projects'), 'project2')
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/362883.html
