Copied to clipboard

Flag this post as spam?

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


  • dillorscroft 198 posts 192 karma points
    Feb 11, 2010 @ 18:37
    dillorscroft
    0

    XSLT Search

    Using XSLTSearch is it possible to return nodes where only the whole of the word matches the search phrase?

    I have a client with a particular desire to tie down the results to only the search term.

    They are selling cleaning products and don't want a search for rag to return fragranced cleaning sprays for example.   <-- This was their example by the way but I got the point!

    Thanks

    DC.

  • Chris Koiak 700 posts 2626 karma points
    Feb 11, 2010 @ 19:32
    Chris Koiak
    0

    Quick fix... you could modify the search to append a space or period to the end of the search?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 11, 2010 @ 19:38
    Nik Wahlberg
    1

    No offense to @Drobar at all as XSLTSearch rocks! But, for wild card searching and more flexibility with search terms, I've found Examine to be great. 

    http://www.farmcode.org/page/Umbraco-Examine.aspx

    Is it an option for you to change?

    Thanks,
    Nik

  • dillorscroft 198 posts 192 karma points
    Feb 12, 2010 @ 13:58
    dillorscroft
    0

    It's a product search and the results pages are quite customised already with images etc.  I'd prefer not to change really as I think the search is great.

    I've a very picky customer.....

    DC

  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Feb 14, 2010 @ 16:48
    Douglas Robar
    0

    You'll need to customize the search (obviously). In the section where the nodes are being selected that have matches you'll want to add some logic for whole words only. Probably use a C# helper function since xslt is overly verbose when making string handling functions.

    I did something like this once and basically created a list of letters that were acceptable in words (a-zA-Z) and did a bit of regex. That obviously wouldn't work in every language but it was enough for the project I was working on. A similar approach would be to define all the white space and other characters that would mark a boundary (whitespace punctuation etc.) as well as checking for the first and last word in the docType property.

    If you're stumpted let me know and I'll see if I can dig out the (not-pretty-but-it-worked-for-me) code.

    cheers,
    doug.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies