I am looking for a master index query that will return the latest version of any item. In the solr index there is a field call _latestversion. But when I add that to my query, I get the error

Find-Item : No property or field '_latestversion' exists in type 'SearchResultItem'

Here is my query

$items = Find-Item -Index sitecore_master_index -Where '(TemplateId=@0 Or TemplateId=@1) And Path.Contains(@2) And _latestversion=true' -WhereValues $clubTemplateId, $wogTemplateId, $roothPath | Initialize-Item

I could use a Get-Item for each result, but that is overkill.

2 Answers 2


If you are using SPE 6.0 this might work for you. Introduced with this issue.

class ExtendedSearchResultItem : SearchResultItem

$props = @{
    Index = "sitecore_master_index"
    Where = "IsLatestVersion == @0"
    WhereValues = $true
    QueryType = [ExtendedSearchResultItem]

Find-Item @props -First 10

If you want to use _latestVersion with Find-Item command then you will need to use -Criteria instead of -Where because -Where uses SearchResultItem class to map the properties whereas -Criteria work directly against Solr fields.

Example -

$clubTemplateId = New-Object Sitecore.Data.ID::new("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}")  
$wogTemplateId = New-Object Sitecore.Data.ID::new("{716FD1F8-FB35-40FA-A144-B0A6BA96E967}") 

$roothPath = "/sitecore/content"    

$idHelper = New-Object Sitecore.ContentSearch.Utilities.IdHelper

$criteria = @(
                @{Filter = "Contains"; Field = "_fullpath"; Value = $roothPath},
                @{Filter = "ContainsAny"; Field = "_template"; Value = [string[]]@($idHelper::NormalizeGuid($clubTemplateId), $idHelper::NormalizeGuid($wogTemplateId))},
                @{Filter = "Equals"; Field = "_latestversion"; Value = "1"}

$items =Find-Item -Index sitecore_master_index -Criteria $criteria | Initialize-Item

Write-Host $items.Length

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.