ב-Knowledge Catalog (לשעבר Dataplex Universal Catalog) אתם יכולים לייבא בכמות גדולה מילוני מונחים, קטגוריות, מונחים וקישורים לרשומות באמצעות Dataplex API. אתם יכולים להשתמש בתהליך הזה כדי לבצע מיגרציה של מטא-נתונים מכלי קיטלוג אחרים או לבצע עדכון מספר פריטים בו-זמנית במילוני המונחים הקיימים.
לפני שמתחילים
לפני שמתחילים בתהליך הייבוא, צריך להשלים את הדרישות המוקדמות הבאות:
יצירת קטגוריה של Cloud Storage
יוצרים קטגוריה של Cloud Storage שתשמש כסביבת Staging, שבה מעלים קובצי JSON לייבוא.
התפקידים הנדרשים
כדי לקבל את ההרשאות שדרושות לייבוא של מילוני מונחים וקישורים לערכים באמצעות קובצי JSON, בקשו מהאדמין להקצות לכם את התפקידים הבאים ב-IAM:
- Dataplex Metadata Editor (
roles/dataplex.metadataEditor) בפרויקט - צפייה באובייקטים באחסון (
roles/storage.objectViewer) בקטגוריה שמכילה את קובצי הייבוא
להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.
יכול להיות שאפשר לקבל את ההרשאות הנדרשות גם באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש.
הפעלת ממשקי ה-API
כדי לייבא מילוני מונחים וקישורים לרשומות, צריך להפעיל את Dataplex API בפרויקט.
התפקידים שנדרשים כדי להפעיל ממשקי API
כדי להפעיל ממשקי API, צריך את ההרשאה serviceusage.services.enable. אם יצרתם את הפרויקט, סביר להניח שכבר יש לכם את ההרשאה הזו דרך התפקיד "בעלים" (roles/owner). אחרת, תוכלו לקבל את ההרשאה הזו דרך התפקיד "אדמין בממשק 'שימוש בשירות'" (roles/serviceusage.serviceUsageAdmin). איך מקצים תפקידים
ייבוא מילוני מונחים באמצעות קובצי JSON
כדי לייבא מילוני מונחים, קטגוריות ומונחים באמצעות העלאת קובצי JSON ל-Cloud Storage, צריך לבצע את המשימות הבאות.
יצירת מילון מונחים לתרגום
יוצרים מילון מונחים לתרגום כדי לייבא מטא-נתונים.
alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"' gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries?glossary_id=GLOSSARY_ID -d "$(cat<<EOF { "displayName": "DISPLAY_NAME", "description": "DESCRIPTION" } EOF )"
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט שבו יוצרים את מילון המונחים -
LOCATION_ID: המיקום שבו רוצים ליצור את מילון המונחים -
GLOSSARY_ID: מזהה מילון המונחים -
DISPLAY_NAME: השם המוצג של מילון המונחים -
DESCRIPTION: תיאור מילון המונחים
הכנת קובצי JSON
יוצרים קובץ JSON עם מפריד שורה חדשה, שכולל את מילון המונחים, הקטגוריות והמונחים שרוצים להעלות לקטגוריה של Cloud Storage.
כדי ליצור את המבנה של קובצי הייבוא, משתמשים בסכימת ה-JSON הבאה:
{"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-category","aspects":{"dataplex-types.global.glossary-category-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","displayName":"CATEGORY_NAME","description":"CATEGORY_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"}]}}} {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM1_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-term","aspects":{"dataplex-types.global.glossary-term-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"TERM1_CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM1_ID","displayName":"TERM1_DISPLAY_NAME","description":"TERM1_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"},{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary-category"}]}}} {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM2_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-term","aspects":{"dataplex-types.global.glossary-term-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"TERM1_CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM2_ID","displayName":"TERM2_DISPLAY_NAME","description":"TERM2_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"},{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary-category"}]}}}
ייבוא מילון מונחים, קטגוריות ומונחים
מייבאים את מילון המונחים, הקטגוריות והמונחים לקטגוריה של Cloud Storage:
# Set GCURL alias alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"' gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF { "type":"IMPORT", "import_spec":{ "log_level":"DEBUG", "source_storage_uri":"gs://STORAGE_BUCKET/", "entry_sync_mode":"FULL", "aspect_sync_mode":"INCREMENTAL", "scope":{ "glossaries": "GLOSSARY_NAME" } } } EOF )"
מחליפים את DATAPLEX_API בנקודת הקצה של Dataplex API בפורמט dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID.
ייבוא קישורים לרשומות באמצעות קובצי JSON
כדי לייבא קישורי רשומות בכמות גדולה באמצעות העלאת קובצי JSON ל-Cloud Storage, צריך לבצע את המשימות הבאות.
הכנת קובצי JSON
יוצרים קובץ JSON עם שורות מופרדות, שמכיל את הקישורים לרשומות שרוצים להעלות לקטגוריה של Cloud Storage.
כדי ליצור את המבנה של קובצי הייבוא, משתמשים בסכימת ה-JSON הבאה:
פורמט לדוגמה של קישורים בין מונחים
{"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-0606e3f2-8206-4f3a-aba9-32c6196f6048","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/synonym","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-2"}]}} {"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-2f7408e3-af3d-405d-81bb-861cf9ec5146","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/related","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-2"}]}}
פורמט לדוגמה של קישורים בין מונחים לנכסי נתונים
{"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-0606e3f2-8206-4f3a-aba9-32c6196f6048","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/definition","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/us-central1/entryGroups/entry-group-1/entries/entry-1"}]}}
ייבוא קישורים בין מונחים כמילים נרדפות או כמונחים קשורים
כדי להתחיל משימת ייבוא של מטא-נתונים שיוצרת קשרי synonym או related בין המונחים בקטלוג, משתמשים בפקודה הבאה:
gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF { "type":"IMPORT", "import_spec":{ "log_level":"DEBUG", "source_storage_uri":"gs://STORAGE_BUCKET/", "entry_sync_mode":"FULL", "aspect_sync_mode":"INCREMENTAL", "scope":{ "entry_groups":[ "projects/PROJECT_ID/locations/LOCATION_ID/entryGroups/@dataplex" ], "entry_link_types":[ "projects/dataplex-types/locations/global/entryLinkTypes/synonym", "projects/dataplex-types/locations/global/entryLinkTypes/related" ], "referenced_entry_scopes":[ "PROJECT_IDS" ] } } } EOF )"
מחליפים את DATAPLEX_API ב-dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID.
ייבוא קישורים בין מונחים לבין נכסי נתונים או עמודות ספציפיים
כדי ליצור קישור בין מונחים במילון המונחים לבין נכסי נתונים, מריצים את משימת הייבוא לכל קבוצת רשומות שאליה שייכת הרשומה של נכס הנתונים. כל הקישורים לרשומות של הגדרות נוצרים בקבוצת הרשומות הזו.
gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF { "type":"IMPORT", "import_spec":{ "log_level":"DEBUG", "source_storage_uri":"gs://STORAGE_BUCKET/", "entry_sync_mode":"FULL", "aspect_sync_mode":"INCREMENTAL", "scope":{ "entry_groups":[ "projects/PROJECT_ID/locations/ENTRY_GROUP_LOCATION_ID/entryGroups/@dataplex" ], "entry_link_types":[ "projects/dataplex-types/locations/global/entryLinkTypes/definition" ], "referenced_entry_scopes":[ "PROJECT_IDS" ] } } } EOF )"
מחליפים את DATAPLEX_API ב-dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID.
מעקב אחרי הסטטוס של משימת הייבוא
כדי לקבל את הסטטוס של הפעולה
import, מריצים את הפקודה הבאה:gcurl https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/operations/operation-OPERATION_IDמחליפים את
OPERATION_IDבמזהה הפעולה.כדי לקבל את הסטטוס של משימת המטא-נתונים, מריצים את הפקודה הבאה:
gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/metadataJobs/JOB_ID
המאמרים הבאים
- איך מנהלים את מילוני המונחים הארגוניים ב-Knowledge Catalog
- איך מייבאים מילוני מונחים מגיליון אלקטרוני ב-Google Sheets
- מידע נוסף על ניהול מטא-נתונים