Skip to content

Commit

Permalink
path and __Published are required to be in the index if you want to u…
Browse files Browse the repository at this point in the history
…se ContentSetValueValidator

This code checks path and published when deciding whether to filter the document without them nothing is indexed!
  • Loading branch information
marcemarc committed Apr 27, 2023
1 parent d9d5756 commit 5a1fc84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ public void Configure(string name, LuceneDirectoryIndexOptions options)

options.FieldDefinitions = new(
new("id", FieldDefinitionTypes.Integer),
new("name", FieldDefinitionTypes.FullText)
new("name", FieldDefinitionTypes.FullText),
//the examine dashboard uses nodeName in search results
new("nodeName", FieldDefinitionTypes.InvariantCultureIgnoreCase),
//__Published and path both required if using the ContentValueSetValidator
new("__Published", FieldDefinitionTypes.Raw),
new("path",FieldDefinitionTypes.InvariantCultureIgnoreCase)
);

options.UnlockIndex = true;

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

if (_settings.Value.LuceneDirectoryFactory == LuceneDirectoryFactory.SyncedTempFileSystemDirectoryFactory)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Examine;
using Examine;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Infrastructure.Examine;

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

};

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

0 comments on commit 5a1fc84

Please sign in to comment.