Announcement

Collapse
No announcement yet.

How can I match plurals in the search? Version 7

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can I match plurals in the search? Version 7

    I was having problems with my Actinic Catalog Version 7 site when search words were plurals (or not as the case may be) in that the search results did not bring up all relevant results, so I searched for a solution and found the solution below:-
    _______________________________________

    How can I match plurals in the search?
    Sometimes if you have the word 'apples' in your product description, you want people to be able to find that product if they search for the word 'apple' (without the 's'). This little addition to the Perl script will take care of that.
    Open 'Search.pm' (from within your site directory) in Notepad or a similar editor.

    Find the line:

    # Combine any multiple-white-spaces into single space

    Place the following lines just above that line:

    $$psSearchString =~ s/es$//io;
    $$psSearchString =~ s/s$//io;
    $$psSearchString =~ s/es\b//io;
    $$psSearchString =~ s/s\b//io;

    ____________________________________

    HOWEVER, this seems to be for a later version of Actinic catalog. So I opened the perlscript in version 7 site folder and found the following:-

    ___________________________________

    #
    # trim excess leading and trailing white space
    #
    $sSearchValue =~ s/^\s*//o;
    $sSearchValue =~ s/\s*$//o;
    #
    _____________________________________

    I then took the code from the other solution and adjusted it and inserted the 4 lines above the existing lines as so (using basic text editor):-

    _____________________________________

    #
    # trim excess leading and trailing white space
    #
    $sSearchValue =~ s/es$//io;
    $sSearchValue =~ s/s$//io;
    $sSearchValue =~ s/es\b//io;
    $sSearchValue =~ s/s\b//io;

    $sSearchValue =~ s/^\s*//o;
    $sSearchValue =~ s/\s*$//o;
    #
    ______________________________________

    I saved the file and updated the site and....hey it all seems to work ok, no more missed products because someone searched for 'guitar' instead of 'guitars' etc.

    I'm sure there are coders out there who could improve this or may say woa you can't put that there, but hey it works for me so I'm happy

    Hope this is of use to someone.

    #2
    You want to trim the whitespace before testing for particular values:

    $sSearchValue =~ s/^\s*//o;
    $sSearchValue =~ s/\s*$//o;

    $sSearchValue =~ s/es$//io;
    $sSearchValue =~ s/s$//io;
    $sSearchValue =~ s/es\b//io;
    $sSearchValue =~ s/s\b//io;

    Also, you might want to add these line to pick up words like "empties" (couldn't think of a better example)
    $sSearchValue =~ s/ies$/y/io;
    $sSearchValue =~ s/es$//io;
    $sSearchValue =~ s/s$//io;
    $sSearchValue =~ s/ies\b/y/io;
    $sSearchValue =~ s/es\b//io;
    $sSearchValue =~ s/s\b//io;

    Comment


      #3
      Originally posted by matty View Post
      Open 'SearchScript.pl' (from within your site directory)
      This should say 'Search.pm'.

      Post #1 was copied from an erroneous KB article since corrected. That's probably why the OP couldn't find the quoted line, but did find something similar.

      Unsurprisingly, shoving the tweak in the wrong file doesn't seem to have any effect!
      Paul
      Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

      Using V10.2 with Norman's brilliantly simple TABBER.

      Comment


        #4
        I have updated post 1 in this thread to correct the perl file which requires editing as mentioned in the post immediately above.

        Comment

        Working...
        X