Panduan memulai ini memperkenalkan Anda pada Entity Reconciliation API. Dalam panduan memulai ini, Anda akan menggunakan konsol Google Cloud untuk menyiapkan Google Cloud project dan autentikasi, membuat file pemetaan skema, lalu membuat permintaan agar Enterprise Knowledge Graph menjalankan tugas rekonsiliasi entitas.
Membuat tugas rekonsiliasi entity
Gunakan langkah-langkah berikut untuk membuat tugas rekonsiliasi entity:
REST
Untuk membuat tugas sederhana dengan satu tabel sumber (penghapusan duplikat), panggil metode projects.locations.entityReconciliationJobs.create.
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
- PROJECT_ID: Project ID Google Cloud Anda.
- LOCATION: Lokasi Grafik Pengetahuan.
- Opsi:
global- Endpoint Global
- Opsi:
- DATASET_ID: ID Set Data BigQuery
- TABLE_ID: ID Tabel BigQuery
- MAPPING_FILE_URI: Jalur Cloud Storage ke file pemetaan dalam format YAML.
- Contoh:
gs://ekg-test-gcs/mapping.yml
- Contoh:
- ENTITY_TYPE: Jenis Entity untuk rekonsiliasi.
Metode HTTP dan URL:
POST https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs
Meminta isi JSON:
{
"inputConfig": {
"bigqueryInputConfigs": [
{
"bigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID",
"gcsUri": "MAPPING_FILE_URI"
}
],
"entityType": "ENTITY_TYPE"
},
"outputConfig": {
"bigqueryDataset": "projects/PROJECT_ID/datasets/DATASET_ID"
}
}
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Simpan isi permintaan dalam file bernama request.json,
dan jalankan perintah berikut:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs"
PowerShell
Simpan isi permintaan dalam file bernama request.json,
dan jalankan perintah berikut:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs" | Select-Object -Expand Content
Anda akan melihat respons JSON seperti berikut:
{
"name": "projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID",
"inputConfig": {
"bigqueryInputConfigs": [
{
"bigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID",
"gcsUri": "MAPPING_FILE_URI"
}
],
"entityType": "ENTITY_TYPE"
},
"outputConfig": {
"bigqueryDataset": "projects/PROJECT_ID/datasets/DATASET_ID"
},
"state": "JOB_STATE_RUNNING",
"createTime": "2021-07-31T14:39:14.145568Z",
"updateTime": "2021-07-31T14:39:14.145568Z"
}
{
"inputConfig": {
"bigqueryInputConfigs": [
{
"bigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID",
"gcsUri": "MAPPING_FILE_URI"
},
{
"bigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID",
"gcsUri": "MAPPING_FILE_URI"
}
],
"entityType": "ENTITY_TYPE",
"previousResultBigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/clusters_13689265293502324307"
},
"outputConfig": {
"bigqueryDataset": "projects/PROJECT_ID/datasets/DATASET_ID"
},
"reconConfig": {
"affinityClusteringConfig": {
"compressionRoundCount": "2"
},
"options": {
"enableGeocodingSeparation": true
}
}
}
Python
Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi Enterprise Knowledge Graph Python API.
Untuk melakukan autentikasi ke Enterprise Knowledge Graph, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.
Mendapatkan tugas rekonsiliasi entity
REST
Untuk mengambil status tugas dari API, panggil metode projects.locations.entityReconciliationJobs.get.
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
- PROJECT_ID: Project ID Google Cloud Anda.
- LOCATION: Lokasi Grafik Pengetahuan.
- Opsi:
global- Endpoint Global
- Opsi:
- JOB_ID: ID Tugas Penyesuaian Entitas.
- Contoh:
2628838070002699773
- Contoh:
Metode HTTP dan URL:
GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Jalankan perintah berikut:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID"
PowerShell
Jalankan perintah berikut:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID" | Select-Object -Expand Content
Anda akan melihat respons JSON seperti berikut:
{
"name": "projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID",
"inputConfig": {
"bigqueryInputConfigs": [
{
"bigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID",
"gcsUri": "MAPPING_FILE_URI"
}
],
"entityType": "ENTITY_TYPE"
},
"outputConfig": {
"bigqueryDataset": "projects/PROJECT_ID/datasets/DATASET_ID"
},
"state": "JOB_STATE_SUCCEEDED",
"createTime": "2021-07-31T14:39:14.145568Z",
"updateTime": "2021-07-31T14:39:14.145568Z"
}
Python
Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi Enterprise Knowledge Graph Python API.
Untuk melakukan autentikasi ke Enterprise Knowledge Graph, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.
Mencantumkan tugas rekonsiliasi entity
REST
Untuk mengambil semua tugas dari API, panggil metode projects.locations.entityReconciliationJobs.list.
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
- PROJECT_ID: Project ID Google Cloud Anda.
- LOCATION: Lokasi Grafik Pengetahuan.
- Opsi:
global- Endpoint Global
- Opsi:
Metode HTTP dan URL:
GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Jalankan perintah berikut:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs"
PowerShell
Jalankan perintah berikut:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs" | Select-Object -Expand Content
Anda akan melihat respons JSON seperti berikut:
{
"entityReconciliationJobs": [
{
"name": "projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID",
"inputConfig": {
"bigqueryInputConfigs": [
{
"bigqueryTable": "projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID",
"gcsUri": "MAPPING_FILE_URI"
}
],
"entityType": "ENTITY_TYPE"
},
"outputConfig": {
"bigqueryDataset": "projects/PROJECT_ID/datasets/DATASET_ID"
},
"state": "JOB_STATE_SUCCEEDED",
"createTime": "2021-07-31T14:39:14.145568Z",
"updateTime": "2021-07-31T14:39:14.145568Z"
}
],
"nextPageToken": ""
}
Python
Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi Enterprise Knowledge Graph Python API.
Untuk melakukan autentikasi ke Enterprise Knowledge Graph, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.
Membatalkan tugas rekonsiliasi entity
REST
Untuk menghentikan tugas yang sedang berjalan dari API, panggil metode projects.locations.entityReconciliationJobs.cancel.
Enterprise Knowledge Graph menghentikan tugas sesegera mungkin. Perhatikan bahwa pembatalan tugas dilakukan berdasarkan upaya terbaik. Keberhasilan perintah cancel tidak dijamin.
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
- PROJECT_ID: Project ID Google Cloud Anda.
- LOCATION: Lokasi Grafik Pengetahuan.
- Opsi:
global- Endpoint Global
- Opsi:
- JOB_ID: ID Tugas Penyesuaian Entitas.
- Contoh:
2628838070002699773
- Contoh:
Metode HTTP dan URL:
POST https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID:cancel
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Jalankan perintah berikut:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID:cancel"
PowerShell
Jalankan perintah berikut:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID:cancel" | Select-Object -Expand Content
Anda akan menerima kode status berhasil (2xx) dan respons kosong.
Python
Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi Enterprise Knowledge Graph Python API.
Untuk melakukan autentikasi ke Enterprise Knowledge Graph, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.
Menghapus tugas rekonsiliasi entity
REST
Untuk menghapus tugas yang selesai atau gagal dengan API, panggil metode projects.locations.entityReconciliationJobs.delete.
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
- PROJECT_ID: Project ID Google Cloud Anda.
- LOCATION: Lokasi Grafik Pengetahuan.
- Opsi:
global- Endpoint Global
- Opsi:
- JOB_ID: ID Tugas Penyesuaian Entitas.
- Contoh:
2628838070002699773
- Contoh:
Metode HTTP dan URL:
DELETE https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Jalankan perintah berikut:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID"
PowerShell
Jalankan perintah berikut:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID" | Select-Object -Expand Content
Anda akan menerima kode status berhasil (2xx) dan respons kosong.
Python
Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi Enterprise Knowledge Graph Python API.
Untuk melakukan autentikasi ke Enterprise Knowledge Graph, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.