Copied to clipboard

Flag this post as spam?

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

  • Urvish 252 posts 776 karma points
    Jul 20, 2016 @ 10:17

    XSLT search : umbraco result + database result


    I am working in the Umbraco 6.0.5 website.

    I have implemented the XSLT search on the site for search functionality.

    Its working fine. It is searching through the Umbraco nodes prefectly.

    But my client needs that it should search through the databse as well.

    For instance, I have seached "Test". Its searching through the Umbraco content and displaying result.. But it should also search through other databse table data and display result with that result.

    Any package available for that?

    Or anyone have done the same before?

    Appreciate if anyone could help.

    Thanks in advance.


    Urvish Mandaliya

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jul 20, 2016 @ 19:43
    Douglas Robar

    You're quite right, XSLTsearch only searches within content pages,not the database directly. A direct database search would be slow, so XSLTsearch uses the in-memory cache of all published content for super-fast searches.

    XSLTsearch has been replaced by ezSearch, which uses Razor rather than XSLT and the Examine Lucene content index rather than the in-memory xml cache. Conceptually, they both do the same things and if you're familiar with how XSLTsearch works then you'll immediately understand how ezSearch works. It's just the ezSearch uses newer technologies and will thus be easier to extend. So going forward I'd recommend ezSearch instead of XSLTsearch.

    In either case, though, neither is doing a brute force search of database tables. But, if you can push database content into an Examine index and then search for it with ezSearch or directly from Examine. This forum thread should help get you started.


  • Urvish 252 posts 776 karma points
    Jul 21, 2016 @ 05:01

    Thanks Doug for the reply.

    I will surely check this and let you know if it worked for me or not.

    Also will check the ezSearch.


    Urvish Mandaliya

  • Urvish 252 posts 776 karma points
    Aug 03, 2016 @ 06:28

    Finally i managed to achieve it in the XSLTSearch file itselt.

    What I did is :

    Added C# code to get the data from the database. Registered that into the XSLT. Append that data with XSLT Search match nodes.

    Below is the code for that :

    Get the data from database using below code :

        <msxsl:script language="C#" implements-prefix="ps">
         public System.Xml.XmlDocument GetList(string str, string delimiter,string searchText)
            string[] items = str.Split(delimiter.ToCharArray(), StringSplitOptions.None);
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            using (System.Xml.XmlWriter writer = doc.DocumentElement.CreateNavigator().AppendChild())
    // Put code here to add database data
                foreach (string item in items)
                    writer.WriteElementString("item", item);
                writer.WriteElementString("item", searchText);
            return doc;

    Get the list in the XSLT :

    <!--Get the search data from the Database-->
      <xsl:variable name="xmlData" select="msxml:node-set(ps:GetList('one,two,three,four,five,six', ',',$search)/*)"></xsl:variable>

    Hope this will work if anyone needs to add this king of functionality.


    Urvish Mandaliya

Please Sign in or register to post replies

Write your reply to: