Copied to clipboard

Flag this post as spam?

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


  • NJ Kennedy 3 posts 23 karma points
    Jul 12, 2010 @ 14:43
    NJ Kennedy
    0

    Searches for more than one word (version 2.8.1)

    Hi

    Using umbraco 4.5 and xsltsearch 2.8.1, I am finding that searches for more than 1 term do not return any results. I believe I know where the problem is - in template booleanAndMatchedNodes - but my xslt knowledge is currently too limited to fix.

    It seems that

    $yetPossibleNodes[@isDoc]/*[not(@isDoc) and (contains($searchFields,name()) and contains(ps:uppercase(umbraco.library:StripHtml(string(.))), $searchTerm)) ]

    is returning the property node rather than the document node, so when the template is recursed further down with the next search term, no @isDoc nodes are found to search against.

    Also, can anyone suggest a way to do a search on any terms rather than on all terms?

    Many thanks.

  • toi 10 posts 25 karma points
    Jul 19, 2010 @ 11:19
    toi
    0

    Hi NJ Kennedy,

    Have you found the solution yet?

    I have the same problem as you. So if you have any solutions, could you please give me some suggestions?

    Thanks.

  • NJ Kennedy 3 posts 23 karma points
    Jul 19, 2010 @ 14:05
    NJ Kennedy
    0

    Unfortunately no. I am imagine it's fairly simple but I spent a couple of hours trying to figure it out without success. Was hoping Mr. Robar would point us in the right direction...

  • toi 10 posts 25 karma points
    Jul 20, 2010 @ 06:08
    toi
    1

    @NJ Kennedy

    After I tried many ways, I found this solution.

    I tried to replace  "

    <

     

     

    xsl:with-param name="yetPossibleNodes" select="$evenYetPossibleNodes"/>

     

     

     

    "

    with

    "

    <

     

     

    xsl:with-param name="yetPossibleNodes" select="$yetPossibleNodes"/>

     

     

     

    ".

    Then it works for me.

    I hope it can be your solution too.

  • Ferdy Hoefakker 214 posts 248 karma points
    Aug 11, 2010 @ 09:03
    Ferdy Hoefakker
    0

    Is Toi's solution the correct answer or is this just a workaround solution? At the very least I can tell that it seems to be working though.

    Kind regards,

    -Ferdy

  • Connie DeCinko 931 posts 1160 karma points
    Sep 23, 2010 @ 20:59
    Connie DeCinko
    0

    Same issue here.  Making that change gave me results, but with no descriptions.  Next answer!

     

  • Chris A 11 posts 32 karma points
    Sep 27, 2010 @ 22:02
    Chris A
    0

    It would be interesting to know whether Toi's fix is "just" a work-around, or is a best-practice solution - anyway - what I can report is that it works with multiple word and phrase searching - thanks Toi !  I get results and descriptions.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 08, 2010 @ 17:29
    Douglas Robar
    2

    The suggested solution is 'just a workaround' and doesn't actually solve the problem. Or rather, it creates another (less obvious) problem.

    The real solution will be released as an updated package to XSLT shortly. But if you're in a hurry you can modify your existing XSLTsearch 2.8.1 (and 2.8.1 only) as follows to fix the multi-word search bug.

     

    Add "/*" after GetXmlAll()

    Search for GetXmlAll(). It only appears once. Change it as shown below.

     <!-- using ALL nodes -->
    <xsl:call-template name="search">
    <xsl:with-param name="items" select="umbraco.library:GetXmlAll()/*"/> <!-- DJR added /* to the end -->
    </xsl:call-template>

     

     

    Replace the booleanAndMatchedNodes template

    The real problem lies in this template and its recursive xpath, and a few anciliary lines of code as well. Rather than noting each line that has changed, just replace the entire template with that shown here.

     <xsl:template name="booleanAndMatchedNodes">
    <xsl:param name="yetPossibleNodes"/>
    <xsl:param name="searchTermList"/>

    <xsl:variable name="searchTerm">
    <xsl:value-of select="ps:getFirstElement($searchTermList, ' ')"/>
    </xsl:variable>
    <xsl:variable name="remainingSearchTermList">
    <xsl:value-of select="ps:removeFirstElement($searchTermList, ' ')"/>
    </xsl:variable>

    <xsl:variable name="searchFieldsAttribsOnly">
    <xsl:variable name="sf" select="umbraco.library:Split($searchFields, ',')" />
    <xsl:for-each select="$sf//value">
    <xsl:if test="substring(., 1, 1) = '@'">
    <xsl:text>,</xsl:text>
    <xsl:value-of select="substring-after(., '@') "/>
    <xsl:text>,</xsl:text>
    </xsl:if>
    </xsl:for-each>
    </xsl:variable>

    <xsl:variable name="attribNodes" select="$yetPossibleNodes[@isDoc
    and attribute::*[
    contains($searchFieldsAttribsOnly,concat(',', name(), ','))
    and contains(ps:uppercase(umbraco.library:StripHtml(string(.))), $searchTerm)
    ]
    ]" />

    <xsl:variable name="propertyNodes" select="$yetPossibleNodes/*[count(@isDoc) = 0
    and contains($searchFields,concat(',', name(), ','))
    and contains(ps:uppercase(umbraco.library:StripHtml(string(.))), $searchTerm)
    ]/.." />

    <xsl:variable name="evenYetPossibleNodes" select="$attribNodes | $propertyNodes" />

    <xsl:choose>
    <xsl:when test="string-length($remainingSearchTermList) &gt; 1">
    <!-- continue to search the rest of the terms -->
    <xsl:call-template name="booleanAndMatchedNodes">
    <xsl:with-param name="yetPossibleNodes" select="$evenYetPossibleNodes"/>
    <xsl:with-param name="searchTermList" select="$remainingSearchTermList"/>
    </xsl:call-template>
    </xsl:when>

    <xsl:otherwise>
    <!-- finished searching: return a list of the attribute @id's of the currently possible nodes as the final set of matched nodes -->
    <xsl:variable name="nodeIDList">
    <xsl:text>;</xsl:text>
    <xsl:for-each select="$evenYetPossibleNodes">
    <!-- @id for this node -->
    <xsl:choose>
    <xsl:when test="@isDoc">
    <xsl:value-of select="@id"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="../@id"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:text>;</xsl:text>
    </xsl:for-each>
    </xsl:variable>

    <!-- return the actual list of id's -->
    <xsl:value-of select="$nodeIDList"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

     

    These fixes will appear in XSLTsearch 2.8.2 and all subsequent versions. I have a number of other fixes to implement and may skip 2.8.2 and may jump right to the 2.9 or 3.0 release. But as I say, all future releases will have this fix for multiple word searches.

    cheers, and my apologies for the bug in the first place,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft