https://discord.umbraco.com logo
#help-with-umbraco
{SOLVED] Add field to internal index (internal search) v10
# help-with-umbraco
s

siempresteve

01/26/2024, 4:00 PM
Have a code field that the admins would like to use in the Umbraco internal backoffice search. I've tried adding this field to the internal index (pretty sure that's what's used in the internal search?). I can see this code getting hit on startup but doesn't seem to affect the search results. Can anyone spot any issues? using Examine; using Examine.Lucene; using Microsoft.Extensions.Options; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Composing; namespace ZZ.Web.v10.Extensions { public class ConfigureInternalIndexOptions : IConfigureNamedOptions { public void Configure(string name, LuceneDirectoryIndexOptions options) { if (name.Equals(Constants.UmbracoIndexes.InternalIndexName)) { options.FieldDefinitions.AddOrUpdate(new FieldDefinition("code", FieldDefinitionTypes.FullText)); } } public void Configure(LuceneDirectoryIndexOptions options) { throw new System.NotImplementedException(); } } public class ExamineComposer : IComposer { public void Compose(IUmbracoBuilder builder) { builder.Services.ConfigureOptions(); } } }
j

jespermayntzhusen

01/29/2024, 8:10 AM
You need to specify the fields the backoffice search should use: https://docs.umbraco.com/umbraco-cms/extending/backoffice-search
Perfect! Thanks - not sure how I missed that in my various searches to solve this! Works perfectly now.
s

Sebastiaan

01/30/2024, 12:01 PM
Ps: three backticks (+language) will make your code more readable in the future. example:
Copy code
csharp
using Examine;
using Examine.Lucene;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;

namespace ZZ.Web.v10.Extensions
{
    public class ConfigureInternalIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
    {

... etc
2 Views