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!
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.
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.
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.
Quick fix... you could modify the search to append a space or period to the end of the search?
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
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
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.
is working on a reply...