Define search policies
You must add the following policies to the Plugin.Search.PolicySet.1.0.0.json file (or to each environment JSON file) when you set up an index.
Search Scope policy
The Search Scope policy defines the search scope name (which matches the index name), the type of entity to be added to the index, a set of tags for adding or removing data from the search results, and the list to be watched for the entity.
{
"$type": "Sitecore.Commerce.Plugin.Search.SearchScopePolicy, Sitecore.Commerce.Plugin.Search",
"Name": "YOUR SEARCH SCOPE NAME",
"IncrementalListName": "YOUR INCREMENTAL LIST NAME",
"FullListName": "YOUR FULL LIST NAME",
"DeletedListName": "YOUR DELETED LIST NAME",
"EntityTypeNames": "YOUR ENTITY NAME",
"ResultDetailsTags": {
"$type": "System.Collections.Generic.List`1[[Sitecore.Commerce.Core.Tag, Sitecore.Commerce.Core]], mscorlib",
"$values": [
{
"$type": "Sitecore.Commerce.Core.Tag, Sitecore.Commerce.Core",
"Name": "YOUR TAG"
},
{
"$type": "Sitecore.Commerce.Core.Tag, Sitecore.Commerce.Core",
"Name": "ANOTHER TAG"
}
]
}
}Indexable policy
The Indexable policy defines the settings for the index, what fields the index has, their type, whether or not they are searchable, filterable, and so on. You can only set one field as key (otherwise the system throws an error when creating or updating the index). The SearchScopeName must match the name of the SearchScopePolicy.
{
"$type": "Sitecore.Commerce.Plugin.Search.IndexablePolicy, Sitecore.Commerce.Plugin.Search",
"SearchScopeName": "YOUR SEARCH SCOPE NAME",
"Properties": {
"PROPERTY1": {
"TypeName": "System.String",
"IsKey": true, [ONLY ONE PROPERTY CAN BE KEY]
"IsSearchable": true,
"IsFilterable": false,
"IsSortable": false,
"IsFacetable": false,
"IsRetrievable": true
},
"PROPERTY2": {
"TypeName": "System.String",
"IsKey": false,
"IsSearchable": true,
"IsFilterable": true,
"IsSortable": true,
"IsFacetable": false,
"IsRetrievable": true
},
"PROPERTY3": {
"TypeName": "System.DateTimeOffset",
"IsKey": false,
"IsSearchable": false,
"IsFilterable": true,
"IsSortable": true,
"IsFacetable": false,
"IsRetrievable": true
},
"ArtifactStoreId": {
"TypeName": "System.String",
"IsKey": false,
"IsSearchable": false,
"IsFilterable": true,
"IsSortable": false,
"IsFacetable": false,
"IsRetrievable": false
}
}
} The ArtifactStoreId is a required field when multiple environments share an index. The ArtifactStoreId field determines what data an environment can add, remove or retrieve.
Search View policy
The SearchView policy defines the settings for the search and search results entity views.
When a view is requested, a block in the IGetEntityViewPipeline checks the SearchViewPolicy for the requested view. If the Search View policy contains a reference to the requested view, the pipeline adds the search view as a child of the requested view.
{
"$type": "Sitecore.Commerce.Plugin.Search.SearchViewPolicy, Sitecore.Commerce.Plugin.Search",
"SearchScopeName": "YOUR SCOPE NAME",
"ViewName": "YOUR VIEW NAME",
"PageSize": 10,
"PageSizeOptions":
{
"$type": "System.Collections.Generic.List`1[[System.Int]], mscorlib",
"$values": [
{
"$type": "System.Int",
"Name": 5
},
{
"$type": "System.Int",
"Name": 10
},
{
"$type": "System.Int",
"Name": 25
},
{
"$type": "System.Int",
"Name": 50
},
{
"$type": "System.Int",
"Name": 100
}
]
}