Using ISHRemote how can I filter based on a list of GUIDs?

Hi,

What is the most efficient way to only return objects from server that match a defined list of topic GUIDs?

I currently have the following

$ishObjects = Get-IshFolder -FolderPath $ishFolder -FolderTypeFilter @("ISHModule") -Recurse |
Get-IshFolderContent |
Where-Object {$_.ishref -in 'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
,'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
,'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
,'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
,'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
,'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
,'GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'} | Get-IshDocumentObjData | Out-GridView

Any advice appreciated,

Regards,

Ann

emoji
Parents
  • Hi Ann,

    If you have the opportunity, you want to filter as close to the data as possible. So a filter in the database is more efficient, than a client-side filter (like your Where-Object), where the information was already pulled from database over the application server to the client (your ISHRemote PowerShell session in this case).

    # The LogicalIds, typically GUIDs, are unique in the Tridion Docs repository.
    # They are not like file system file paths, so folder path and filename to be unique.
    
    # An array of logical ids like you have
    $logicalIds = @()
    $logicalIds += 'GUID-A'
    $logicalIds += 'GUID-B'
    $logicalIds += 'GUID-Y'
    $logicalIds += 'GUID-Z'
    
    # If you have a list of LogicalIds of around ~1000 GUIDs, then just do a Get-IShDocumentObj
    Get-IShDocumentObj -LogicalId $logicalIds #-MetadataFilter $metadataFilter
    
    # If the list is larger, than batch prerably by 999 group size. That value is advised over $ishSession.MetadataBatchSize varaible as that is most optimal for performance and throughput of database queries.
    $expectedBatchCount = [int]($logicalIds.Count / $ishSession.MetadataBatchSize)+1 #$ishSession.MetadataBatchSize
    For ($i=0; $i -lt $expectedBatchCount; $i++) {
        $fromIndex = ($i*$ishSession.MetadataBatchSize)
        $toIndex = (($i+1)*$ishSession.MetadataBatchSize)-1
        $logicalIdsBatch = $logicalIds[$fromIndex..$toIndex]
        Write-Host ("Batch["+$i+"] fromIndex["+$fromIndex+"] toIndex["+$toIndex+"] logicalIdsBatch.Count["+$logicalIdsBatch.Count+"]")
        $ishObjects = Get-IshDocumentObj -LogicalId $logicalIdsBatch #-MetadataFilter $metadataFilter
    }

    Hope this gets you going,
    Dave

    emoji
Reply
  • Hi Ann,

    If you have the opportunity, you want to filter as close to the data as possible. So a filter in the database is more efficient, than a client-side filter (like your Where-Object), where the information was already pulled from database over the application server to the client (your ISHRemote PowerShell session in this case).

    # The LogicalIds, typically GUIDs, are unique in the Tridion Docs repository.
    # They are not like file system file paths, so folder path and filename to be unique.
    
    # An array of logical ids like you have
    $logicalIds = @()
    $logicalIds += 'GUID-A'
    $logicalIds += 'GUID-B'
    $logicalIds += 'GUID-Y'
    $logicalIds += 'GUID-Z'
    
    # If you have a list of LogicalIds of around ~1000 GUIDs, then just do a Get-IShDocumentObj
    Get-IShDocumentObj -LogicalId $logicalIds #-MetadataFilter $metadataFilter
    
    # If the list is larger, than batch prerably by 999 group size. That value is advised over $ishSession.MetadataBatchSize varaible as that is most optimal for performance and throughput of database queries.
    $expectedBatchCount = [int]($logicalIds.Count / $ishSession.MetadataBatchSize)+1 #$ishSession.MetadataBatchSize
    For ($i=0; $i -lt $expectedBatchCount; $i++) {
        $fromIndex = ($i*$ishSession.MetadataBatchSize)
        $toIndex = (($i+1)*$ishSession.MetadataBatchSize)-1
        $logicalIdsBatch = $logicalIds[$fromIndex..$toIndex]
        Write-Host ("Batch["+$i+"] fromIndex["+$fromIndex+"] toIndex["+$toIndex+"] logicalIdsBatch.Count["+$logicalIdsBatch.Count+"]")
        $ishObjects = Get-IshDocumentObj -LogicalId $logicalIdsBatch #-MetadataFilter $metadataFilter
    }

    Hope this gets you going,
    Dave

    emoji
Children