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?
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...
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.
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:choose> <xsl:when test="string-length($remainingSearchTermList) > 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.
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.
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.
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...
@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.
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
Same issue here. Making that change gave me results, but with no descriptions. Next answer!
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.
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.
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.
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.
is working on a reply...