執行重新編製索引作業
在某些情況下,您可能在 Azure Health Data Services 的 FHIR® 服務中搜尋參數尚未編製索引。 當您定義自己的自定義搜尋參數時,此案例是相關的。 在編製搜尋參數索引之前,它無法用於即時生產環境。 本文說明如何執行重新編製索引作業,以編製 FHIR 服務資料庫中任何自定義搜尋參數的索引。
警告
在開始使用之前,請務必先閱讀整篇文章。 重新編製索引作業的效能可能會非常密集。 本文討論如何節流和控制重新編製索引作業的選項。
如何執行重新索引作業
您可以針對整個 FHIR 服務資料庫,以及針對特定自定義搜尋參數執行重新索引作業。
在整個 FHIR 服務資料庫上執行重新編製索引作業
若要執行重新編製索引作業,請使用下列 POST
呼叫搭配要求本文中的 JSON 格式化 Parameters
資源。
POST {{FHIR_URL}}/$reindex
content-type: application/fhir+json
{
"resourceType": "Parameters",
"parameter": []
}
"parameter": []
如果您不需要調整配置給重新編製索引作業的資源,請將字段保留空白(如所示)。
如果要求成功,除了回應中的資源之外,您也會收到 201 已建立 的狀態代碼 Parameters
。
HTTP/1.1 201 Created
Content-Location: https://{{FHIR URL}}/_operations/reindex/560c7c61-2c70-4c54-b86d-c53a9d29495e
{
"resourceType": "Parameters",
"id": "560c7c61-2c70-4c54-b86d-c53a9d29495e",
"meta": {
"versionId": "138035"
},
"parameter": [
{
"name": "id",
"valueString": "560c7c61-2c70-4c54-b86d-c53a9d29495e"
},
{
"name": "lastModified",
"valueDateTime": "2023-06-08T04:52:44.0974408+00:00"
},
{
"name": "queuedTime",
"valueDateTime": "2023-06-08T04:52:44.0974406+00:00"
},
{
"name": "totalResourcesToReindex",
"valueDecimal": 0.0
},
{
"name": "resourcesSuccessfullyReindexed",
"valueDecimal": 0.0
},
{
"name": "progress",
"valueDecimal": 0.0
},
{
"name": "status",
"valueString": "Queued"
},
{
"name": "maximumConcurrency",
"valueDecimal": 3.0
},
{
"name": "queryDelayIntervalInMilliseconds",
"valueDecimal": 500.0
},
{
"name": "maximumNumberOfResourcesPerQuery",
"valueDecimal": 100.0
}
]
}
針對特定自定義搜尋參數執行重新編製索引作業
若要針對特定自定義搜尋參數執行重新編製索引作業,請使用下列 POST
呼叫搭配要求主體中的 JSON 格式化 Parameters
資源。
POST {{FHIR_URL}}/$reindex
content-type: application/fhir+json
{
"resourceType": "Parameters",
"parameter": [
{
"name": "targetSearchParameterTypes",
"valueString": "{url of custom search parameter. In case of multiple custom search parameters, url list can be comma separated.}"
}
]
}
注意
若要檢查 的狀態,或取消重新編製索引作業,您需要重新編製索引標識符。 這是 "id"
回應值中 "parameter"
攜帶的 。 在上述範例中,重新編制索引作業的識別碼會是 560c7c61-2c70-4c54-b86d-c53a9d29495e
。
如何檢查重新編製索引作業的狀態
啟動重新編制索引作業之後,您可以使用下列呼叫來檢查作業的狀態。
GET {{FHIR_URL}}/_operations/reindex/{{reindexJobId}}
以下是範例回應。
{
"resourceType": "Parameters",
"id": "560c7c61-2c70-4c54-b86d-c53a9d29495e",
"meta": {
"versionId": "138087"
},
"parameter": [
{
"name": "id",
"valueString": "560c7c61-2c70-4c54-b86d-c53a9d29495e"
},
{
"name": "startTime",
"valueDateTime": "2023-06-08T04:54:53.2943069+00:00"
},
{
"name": "endTime",
"valueDateTime": "2023-06-08T04:54:54.4052272+00:00"
},
{
"name": "lastModified",
"valueDateTime": "2023-06-08T04:54:54.4053002+00:00"
},
{
"name": "queuedTime",
"valueDateTime": "2023-06-08T04:52:44.0974406+00:00"
},
{
"name": "totalResourcesToReindex",
"valueDecimal": 2.0
},
{
"name": "resourcesSuccessfullyReindexed",
"valueDecimal": 2.0
},
{
"name": "progress",
"valueDecimal": 100.0
},
{
"name": "status",
"valueString": "Completed"
},
{
"name": "maximumConcurrency",
"valueDecimal": 3.0
},
{
"name": "resources",
"valueString": "{{LIST_OF_IMPACTED_RESOURCES}}"
},
{
"name": "resourceReindexProgressByResource (CountReindexed of Count)",
"valueString": "{{RESOURCE_TYPE:REINDEXED_COUNT OF TOTAL_COUNT}}"
},
{
"name": "searchParams",
"valueString": "{{LIST_OF_SEARCHPARAM_URLS}}"
},
{
"name": "queryDelayIntervalInMilliseconds",
"valueDecimal": 500.0
},
{
"name": "maximumNumberOfResourcesPerQuery",
"valueDecimal": 100.0
}
]
}
上述回應中會顯示下列資訊:
totalResourcesToReindex
:包含正在重新編制此作業索引的資源總數。resourcesSuccessfullyReindexed
:此作業中已重新編製索引的資源總數。progress
:完成重新編製作業百分比。resourcesSuccessfullyReindexed
/totalResourcesToReindex
等於 x 100。status
:如果重新編製索引作業已排入佇列、執行、完成、失敗或取消,則為狀態。resources
:列出受重新編製索引作業影響的所有資源類型。'resourceReindexProgressByResource (CountReindexed of Count)':為每個資源類型提供總計數的重新編製索引計數。 如果特定資源類型的重新編製索引已排入佇列,則只會提供 Count。
'searchParams':列出受重新編製索引作業影響之搜尋參數的 URL。
刪除重新編製索引作業
如果您需要取消重新編製索引作業,請使用 DELETE
呼叫並指定重新編製索引作業標識碼。
DELETE {{FHIR URL}}/_operations/reindex/{{reindexJobId}}
效能考量
重新編製索引作業的效能可能會相當密集。 FHIR 服務提供節流控制,以協助管理重新編製索引作業在資料庫上執行的方式。
注意
在大型數據集上,重新編製索引作業執行數天並不罕見。
下表概述可用來控制重新編製作業計算資源索引的可用參數、預設值和建議範圍。 您可以使用這些參數來加速程式(使用更多計算)或降低程式速度(使用較少的計算)。
參數 | 說明 | Default | 可用的範圍 |
---|---|---|---|
QueryDelayIntervalInMilliseconds |
重新編製索引作業期間開始每個資源批次之間的延遲。 較小的數位會加速工作,而較大的數位會降低作業速度。 | 500 毫秒 (.5 秒) | 50 到 500000 |
MaximumResourcesPerQuery |
要重新編製索引之批次中包含的資源數目上限。 | 100 | 1-5000 |
MaximumConcurrency |
一次完成的批次數目。 | 1 | 1-10 |
如果您想要使用上述任何參數,您可以在傳送初始POST
要求以啟動重新編製索引作業時,將它們傳遞至Parameters
資源。
POST {{FHIR_URL}}/$reindex
content-type: application/fhir+json
{
"resourceType": "Parameters",
"parameter": [
{
"name": "maximumConcurrency",
"valueInteger": "3"
},
{
"name": "queryDelayIntervalInMilliseconds",
"valueInteger": "1000"
},
{
"name": "maximumNumberOfResourcesPerQuery",
"valueInteger": "1"
}
]
}
下一步
在本文中,您已瞭解如何在 FHIR 服務中執行重新編製索引作業。 若要瞭解如何定義自定義搜尋參數,請參閱
注意
FHIR® 是 HL7 的註冊商標,在 HL7 的許可下使用。