Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dominik Pöhacker 8 posts 98 karma points
    Nov 15, 2022 @ 11:03
    Dominik Pöhacker
    0

    Adding custom properties to backoffice search

    Hi all,

    I'm trying to add custom properties to backoffice search in Umbraco 8. I followed the documentation:

    https://our.umbraco.com/Documentation/Extending/Backoffice-Search/index-v8_6

    But it still not working.

    I added the composer:

    public class UmbracoTreeSearcherFieldsComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            composition.RegisterUniqueFor<IUmbracoTreeSearcherFields, CustomUmbracoTreeSearcherFields>();
        }
    }
    

    And I created my custom tree searcher class:

    public class CustomUmbracoTreeSearcherFields : UmbracoTreeSearcherFields
    {
        public CustomUmbracoTreeSearcherFields(ILocalizationService localizationService) : base(localizationService)
        {
        }
    
        public override IEnumerable<string> GetBackOfficeDocumentFields()
        {
            return new List<string>(base.GetBackOfficeDocumentFields()) { "contentBlock" };
        }
    }
    

    Any suggestions why it is not working?

  • Corné Hoskam 80 posts 587 karma points MVP 2x c-trib
    Nov 15, 2022 @ 12:02
    Corné Hoskam
    0

    Hi Dominik,

    Could you let me know which specific Umbraco version (major, minor, patch) you are using, and what datatype the "contentBlock" property is?

    Kind regards,

    Corné

    EDIT: On second glance, before answering, could you try and add the IInternalSearchConstants interface on your CustomUmbracoTreeSearcherFields class? It appears as though that could be part of what's missing!

  • Dominik Pöhacker 8 posts 98 karma points
    Nov 15, 2022 @ 12:39
    Dominik Pöhacker
    0

    Hi Corné,

    I using the latest version 8.15.5. That's not the correct property in this snippet, but I want to add a nested content property. I added this property also for my frontend examine search and it works great.

    I tried to add the IInternalSearchConstants interface, but I'm not sure. Do I have to add something in there? I tried also with IUmbracoTreeSearcherFields. It still not working.

  • Corné Hoskam 80 posts 587 karma points MVP 2x c-trib
    Nov 15, 2022 @ 12:51
    Corné Hoskam
    0

    Hi Dominik,

    Even though Nested Content is stored as JSON, in theory you should be able to search through it using Examine. Could you check if the property name is correct, using the Examine Management Dashboard under Settings?

    Try searching for the page you're looking for in the ExternalIndex, and click on the "## fields" button to see the indexed Field values, which should hopefully tell you all the indexed properties of your document.

  • Dominik Pöhacker 8 posts 98 karma points
    Nov 15, 2022 @ 13:06
    Dominik Pöhacker
    0

    Hi Corné,

    I don't get results in the ExternalIndex, only in InternalIndex. Is this why it not works? Property name is definitely correct and I can find it only in InternnalIndex?! But it works for my frontend solution. In ExternalIndex I only get media stuff.

  • Corné Hoskam 80 posts 587 karma points MVP 2x c-trib
    Nov 15, 2022 @ 13:29
    Corné Hoskam
    0

    My apologies, you are correct, the InternalIndex is used for the back-office search and contains published & unpublished content, the ExternalIndex is used for building your own search implementation!

    For the issue itself... without reproducing it myself at this moment I am stumped... I'll see if I can reproduce your setup at a later point in time, but I have a feeling that the issue is because your property is of type Nested Content. If anyone else has any suggestions in the meantime, feel free!

  • Dominik Pöhacker 8 posts 98 karma points
    Nov 15, 2022 @ 13:52
    Dominik Pöhacker
    0

    I'm sure it work with Nested Content. I tried it with another property of type Repeatable textstrings and it still not working. I using both properties for my frontend search solution and there it works. I don't know what is missing, but I think the properties are fine.

    Thank you for your help and time Corné.

Please Sign in or register to post replies

Write your reply to:

Draft