【发布时间】:2015-12-28 11:57:34
【问题描述】:
我使用 Sitecore PowerShell Extensions 模块创建脚本,将关系从一项复制到相关项。
我使用Get-ChildItem 来获取与特定字段相关的所有项目
Get-ChildItem -Recurse . | Where-Object {
$_.TemplateName -match $'myTemplate' -and
$_.Fields[$fromfield].Value -ne $null -and
$_.Fields[$fromfield].Value -ne ""
} | ForEach-Object {
}
我花了大约 1 分钟来获取所有项目,因为数据很大。
所以我尝试使用Find-Item 让搜索过程更快
Find-Item -Index 'sitecore_mastre_index' -Where 'TemplateName = @0' -WhereValues 'myTemplate'
它给了我以下警告,请注意我使用的是 Sitecore 版本 7.2
警告:由于平台限制,此版本的 Sitecore 不支持参数 Where。
从 Sitecore 版本 7.5 开始支持此参数
有没有办法使用 PowerShell 以比使用 Get-ChildItem 更快的方式检索数据?
注意:如果我使用Get-Item .,则查询仅返回前 100 个项目。我还有很多东西。
【问题讨论】:
-
如果不了解更多关于变量的信息,很难说。 Get-Childitem 的 exclude/include/filter 参数你试过了吗?
标签: powershell sitecore