Skip to content

Commit 5a1fc84

Browse files
committed
path and __Published are required to be in the index if you want to use ContentSetValueValidator
This code checks path and published when deciding whether to filter the document without them nothing is indexed!
1 parent d9d5756 commit 5a1fc84

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Umbraco.Docs.Samples.Web/CustomIndexing/ConfigureProductIndexOptions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ public void Configure(string name, LuceneDirectoryIndexOptions options)
3535

3636
options.FieldDefinitions = new(
3737
new("id", FieldDefinitionTypes.Integer),
38-
new("name", FieldDefinitionTypes.FullText)
38+
new("name", FieldDefinitionTypes.FullText),
39+
//the examine dashboard uses nodeName in search results
40+
new("nodeName", FieldDefinitionTypes.InvariantCultureIgnoreCase),
41+
//__Published and path both required if using the ContentValueSetValidator
42+
new("__Published", FieldDefinitionTypes.Raw),
43+
new("path",FieldDefinitionTypes.InvariantCultureIgnoreCase)
3944
);
4045

4146
options.UnlockIndex = true;
4247

43-
options.Validator = new ContentValueSetValidator(true, false, _publicAccessService, _scopeProvider, includeItemTypes: new[] { "product" });
48+
//ContentValueSetValidator - requires Path, and ParentId
49+
options.Validator = new ContentValueSetValidator(true,false, _publicAccessService, _scopeProvider, includeItemTypes: new[] { "product" });
4450

4551
if (_settings.Value.LuceneDirectoryFactory == LuceneDirectoryFactory.SyncedTempFileSystemDirectoryFactory)
4652
{

Umbraco.Docs.Samples.Web/CustomIndexing/ProductIndexValueSetBuilder.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Examine;
1+
using Examine;
22
using Umbraco.Cms.Core.Models;
33
using Umbraco.Cms.Infrastructure.Examine;
44

@@ -14,6 +14,12 @@ public IEnumerable<ValueSet> GetValueSets(params IContent[] contents)
1414
{
1515
["name"] = content.Name,
1616
["id"] = content.Id,
17+
// nodeName used in the Examine Dashboard backoffice search results
18+
["nodeName"] = content.Name,
19+
//__Published and path are required if using core ContentValueSetValidator to apply a Validation option to filter results
20+
["__Published"] = content.Published ? "y" : "n",
21+
["path"] = content.Path
22+
1723
};
1824

1925
yield return new ValueSet(content.Id.ToString(), "content",content.ContentType.Alias,indexValues);

0 commit comments

Comments
 (0)