你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
运行重新编制索引作业
在某些情况下,你可能在 Azure Health Data Services 的 FHIR 服务中具有尚未编制索引的搜索参数。 定义自己的自定义搜索参数时,此方案相关。 在为搜索参数编制索引之前,它不能用于实时生产。 本文介绍如何运行重新编制索引作业,以索引尚未在 FHIR 服务数据库中编制索引的任何自定义搜索参数。
警告
在开始之前请务必阅读整篇文章。 重编索引作业可能会非常耗用性能。 本文讨论有关如何限制和控制重新编制索引作业的选项。
如何运行重新索引作业
可以针对整个 FHIR 服务数据库和特定的自定义搜索参数执行重新索引作业。
对整个 FHIR 服务数据库运行重新编制索引作业
若要运行重新编制索引作业,请在 POST
请求正文中对 JSON 格式 Parameters
的资源使用以下调用:
POST {{FHIR_URL}}/$reindex
content-type: application/fhir+json
{
"resourceType": "Parameters",
"parameter": []
}
"parameter": []
如果不需要调整分配给重新编制索引作业的资源,请将字段留空 (,如) 所示。
如果请求成功,则除了Parameters
响应中的资源外,你还会收到“201 已创建”状态代码。
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。 这是 "id"
响应中 "parameter"
返回的值中携带的 。 在上面的示例中,重编索引作业的 ID 为 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
调用并指定重新编制索引作业 ID:
DELETE {{FHIR URL}}/_operations/reindex/{{reindexJobId}}
性能注意事项
重编索引作业可能会非常耗用性能。 FHIR 服务提供了一些限制控件,可帮助你管理重新编制索引作业在数据库上的运行方式。
注意
重编索引作业在大型数据集上运行数天的情况并不少见。
下表概述了可用于控制重新索引作业计算资源的可用参数、默认值和建议范围。 可以使用这些参数加快进程(使用更多的计算)或减缓进程(使用更少的计算)。
参数 | 说明 | Default | 可用范围 |
---|---|---|---|
QueryDelayIntervalInMilliseconds |
重编索引作业期间启动每批资源之间的延迟。 较小的数字会加速作业,而较大的数字会减慢作业速度。 | 500 MS(0.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 许可使用。