Skip to content

Commit

Permalink
Merge pull request #21 from marcemarc/5142-fix-custom-index-samples
Browse files Browse the repository at this point in the history
5142 fix custom index samples
  • Loading branch information
Jeavon authored Apr 28, 2023
2 parents 6f6408e + 5a1fc84 commit 935fea2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 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
7 changes: 6 additions & 1 deletion Umbraco.Docs.Samples.Web/CustomIndexing/ExamineComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ namespace Umbraco.Docs.Samples.Web.CustomIndexing
public class ExamineComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
{

builder.Services.AddExamineLuceneIndex<ProductIndex, ConfigurationEnabledDirectoryFactory>("ProductIndex");

builder.Services.ConfigureOptions<ConfigureProductIndexOptions>();

builder.Services.AddSingleton<ProductIndexValueSetBuilder>();

builder.Services.AddSingleton<IIndexPopulator, ProductIndexPopulator>();


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ 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", indexValues);
yield return new ValueSet(content.Id.ToString(), "content",content.ContentType.Alias,indexValues);
}
}
}
Expand Down

0 comments on commit 935fea2

Please sign in to comment.