Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 830 posts 2144 karma points
    Feb 09, 2016 @ 09:22
    Claushingebjerg
    0

    making custom image properties searchable

    Is there a simple way to make cutom media properties searchable in the backoffice?

    In the example below, i would like to be able to find photos by photographer and tags, but the media seach only searches the name as default...

    enter image description here

  • Daniel 60 posts 174 karma points
    Feb 09, 2016 @ 18:10
    Daniel
    0

    I've never tried this, but could you try adding the custom property to the internal Examine index?

    In /Config/ExamineIndex.config change:

      <!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
      <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/"/>
    

    to:

    <!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
    <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/">
        <IndexUserFields>
            <add Name="YOUR_FOTOGRAPHER_PROPERTY_ALIAS" />
        <IndexUserFields>
    </IndexSet>
    

    I'm curious if this would work! Don't forget to rebuild the index from the Developer tab!

  • Claushingebjerg 830 posts 2144 karma points
    Feb 10, 2016 @ 07:39
    Claushingebjerg
    0

    Upon further inspection, they are actually already in the index... they just don't return results... :|

    enter image description here

    enter image description here

  • Daniel 60 posts 174 karma points
    Feb 10, 2016 @ 08:26
    Daniel
    0

    Shouldn't your own properties be in:

    <IndexUserFields>
    

    And not:

    <IndexAttributeFields>
    

    As that is only the built in properties?

    Doubt this will have any effect, but worth a shot moving "writerName" into "IndexUserFields" !

  • Claushingebjerg 830 posts 2144 karma points
    Feb 25, 2016 @ 14:14
    Claushingebjerg
    0

    Im back I spotted an obvious error as my custom properties had been added to the member index. Now my Examineindex.config looks like this:

        <ExamineLuceneIndexSets>
      <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/{machinename}/Internal/">
         <IndexUserFields>
          <add Name="tags" />
          <add Name="fotograf" />
        </IndexUserFields>
      </IndexSet>    
    
    
      <IndexSet SetName="InternalMemberIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/{machinename}/InternalMember/">
        <IndexAttributeFields>
          <add Name="id" />
          <add Name="nodeName"/>
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="loginName" />
          <add Name="email" />
          <add Name="nodeTypeAlias" />
        </IndexAttributeFields>
      </IndexSet>
    
      <!-- Default Indexset for external searches, this indexes all fields on all types of nodes-->
      <IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/{machinename}/External/" />
    </ExamineLuceneIndexSets>
    

    But still no luck in making "fotograf" and "Tags searchable"... :( Any Examine experts in the house?

  • Erik Foppen 20 posts 62 karma points
    Mar 06, 2016 @ 15:44
    Erik Foppen
    0

    I need to add user fields to the internal search engine as well. Unfortunately it only searches the nodeName, despite what you include in the index. See http://stackoverflow.com/questions/33255243/searching-other-fields-in-the-internal-backoffice-search-box-v7-1-0.

    Does anyone have an idea for a workaround for this issue?

  • James Patterson 53 posts 192 karma points
    Nov 30, 2017 @ 09:59
    James Patterson
    0

    This is an old-ish thread but I thought I'd post for anyone who finds it in the future as I found it while looking for a solution to this myself.

    A client wants the ability to add tags to media items to make it easier to find them in the back-end media search.

    I decided to delve into the source and, as Erik says above, it seems Umbraco only searches specific fields, primarily nodeName.

    https://github.com/umbraco/Umbraco-CMS/blob/e0025db56d52b770d2b3aedbd48a3b804fd15ef0/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs#L42

    Then nodeName is hardcoded into the query here:

    https://github.com/umbraco/Umbraco-CMS/blob/e0025db56d52b770d2b3aedbd48a3b804fd15ef0/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs#L150

    To get around this issue I thought I'd be clever and put the tags into the same Examine field as the nodeName using an event handler for GatheringNodeData. However, it turns out that the name you see in the search results is what is in the Examine index, not the name of the node from the media item - so it looked pretty bad.

    I ended up doing something similar to the following, which still isn't great, but gives them the functionality they need and the tags are appended in a way that makes it look somewhat deliberate...

    public class MediaExamineEventHandler : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ExamineManager.Instance.IndexProviderCollection["InternalIndexer"].GatheringNodeData += MediaExamineEventHandler_GatheringNodeData;
        }
    
        private void MediaExamineEventHandler_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
        {
            if (e.IndexType == IndexTypes.Media)
            {
                if (e.Fields.ContainsKey("tags"))
                {
                    var tagsValue = e.Fields["tags"].Replace(",", ", ");
    
                    e.Fields["nodeName"] += $" [Tags: {tagsValue}]";
                }
            }
        }
    }
    

    If anyone has a better solution I'd appreciate the input! Until then, I hope this helps somebody.

Please Sign in or register to post replies

Write your reply to:

Draft