0

I am using Sitecore PowerShell Extension with the below script

$indexName = "sitecore_web_index"
$criteria = @(
                @{Filter = "Contains"; Field = "industry_sm"; Value = "{7451A225-6450-4D26-BE04-624FD2E63B76}" },
                @{Filter = "Contains"; Field = "service_sm"; Value = "{0670EE3C-1D07-4172-9ADB-19127D90C180}" }
            )
 $list = Find-Item -Index $indexName -Criteria $criteria | Initialize-Item

The issue is above script returns items that follow both filter conditions is it possible to get items even if it follows only one filter condition

1 Answer 1

1

Try using the below code. I checked a few articles that show that it works with And operator, but you can try with Or operator.

class IndustrySearchResultItem : SearchResultItem
{
   [Sitecore.ContentSearch.IndexField("industry_sm")]
   [string]$Industry
   [Sitecore.ContentSearch.IndexField("service_sm")]
   [string]$Service
}

$props = @{
    Index = "sitecore_master_index"
    Where = "Industry.Contains(@0) Or Service.Contains(@1)"
    WhereValues = "{7451A225-6450-4D26-BE04-624FD2E63B76}", "{0670EE3C-1D07-4172-9ADB-19127D90C180}"
    QueryType = [IndustrySearchResultItem]
}

Find-Item @props

Reference: https://doc.sitecorepowershell.com/appendix/indexing/find-item#where-less-than-string-greater-than

Powershell get all items that use a template

Hope this helps.

Your Answer

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

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