Copied to clipboard

Flag this post as spam?

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

  • Alex Brown 129 posts 620 karma points
    Jun 19, 2018 @ 12:00
    Alex Brown

    Hi All

    I was wondering if anyone has successfully managed to search the External index for a UDI?

    I've got a part of my site where a user can make selections which triggers node ids to be sent to the server. I need to be able to search these ids in Examine. These ids are dictated by a Multinode Treepicker which stores the data as UDIs.

    Since I have the ids I want to search on, I could just convert them to UDIs, however whenever I search all or part of a UDI it returns no results.

    Anyone done something similar?

    I'm aware of NuPickers but I wanted to try avoid using any packages if possible.

  • Søren Kottal 607 posts 3870 karma points MVP 3x c-trib
    Jul 30, 2018 @ 21:21
    Søren Kottal

    Hi Alex

    Problem is, that the UDI is not (by default) indexed in Examine. In stead, the guid (which the UDI is based upon) is. The guid is indexed in the column Key.

    So you could convert your UDI to a Guid, and find what you need.

    Ie. umb://document/4fed18d8c5e34d5e88cfff3a5b457bf2 would need to be transformed into 4fed18d8-c5e3-4d5e-88cf-ff3a5b457bf2.

  • Rachel Breeze 6 posts 80 karma points MVP 2x c-trib
    Sep 11, 2019 @ 07:13
    Rachel Breeze


    So I hit the same issue and resolved it by adding an examine indexer that added a custom field for the UDI

     protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
                .GatheringNodeData += OnGatheringNodeData;
        private void OnGatheringNodeData(object sender, IndexingNodeDataEventArgs e)
            var node = new Node(e.NodeId);
            e.Fields.Add(CmsConstants.ExamineConstants.CATEGORY_FILTER, BuildFilter(node, "categories"));
        public string BuildFilter(Node node, string property)
                var values = node.Properties[property].ToString();
                var ids = new StringBuilder();
                foreach (var id in values.Split(','))
                    if (ids.Length > 0)
                        ids.Append(" ");
                    ids.Append(id.Replace("umb://document/", ""));
                return ids.ToString();

    Then when searching the index by the document, where I had the primary key of the document and not the UDI I used the umbraco helper to get the page by id, something like this (_umbracoHelper is of type UmbracoHelper):

    var page = _umbracoHelper.TypedContent(pageId);

    Then the value to use in examine search becomes:

  • Jamie Attwood 174 posts 427 karma points c-trib
    Dec 12, 2019 @ 17:57
    Jamie Attwood

    I have the same issue and posted another forum question on this. I looks like the umb syntax (containing a colon (:) causes a lucene syntax error because the colon is used as the key/value separator in the raw query.

    In my case, I am searching a members index set and searching against a value of a content picker. That content picker is returning a umb string as I can see it when I search all by removing the search criteria.

    In the end, I had to build a raw query and then add wildcards before the key value and change my search value from a umb to a guid where I stripped out the "-" characters.

    Here is my code for this:

    var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalMemberSearcher"];
    var criteria = searcher.CreateSearchCriteria();
    var contentTypeFilter = string.Format("__IndexType:{0}", UmbracoExamine.IndexTypes.Member);
    var searchKey = "advisor";
    //var searchValue = Udi.Create(Constants.UdiEntityType.Document, currentAdvisor.GetKey()).ToString(); // This does not work as the umb colon causes a lucene sytax error
    var searchValue = currentAdvisor.GetKey().ToString().Replace("-","");
    var query = new StringBuilder();
    query.AppendFormat("+{0} ", contentTypeFilter);
    query.AppendFormat("+({0}:*{1}*)", searchKey, searchValue);
    var searchResults = searcher.Search(criteria.RawQuery(query.ToString()));

    Also, importantly you need to addenableLeadingWildcard="true" to your searcher config in examineSettings.config. I understand this is not performant, but what to do...

Please Sign in or register to post replies

Write your reply to: