Results 1 to 6 of 6

Thread: Add or eliminate spaces from users search

  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Default Add or eliminate spaces from users search

    I have various products on my websites, all with product numbers such as (3KA, 400DKP, etc). I want make it so that if a person places a space inbetween any part of the PN, the search will know to try the query without spaces. Example: the PN is 3KA but the user searches for 3 KA. currently the search will not find the 3KA because it is not 1 word. how can I fix this?

  2. #2
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    3,586

    Default

    I can't think of any simple way to add this functionality without needing to modify the search script code (which you are free to do, but we won't be able to support the resultant modified script).

    If they were dashes or dots, then the Indexing options have Word join rules, which allow say, "3.KA", "3-KA", etc. to also match "3 KA".
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

  3. #3
    Join Date
    Jul 2009
    Posts
    2

    Default

    You can easily check for whitespace, the modification needed is likely minimal, and will be easy to revert later, if needed.

    I would think something like the below would be enough.

    Code:
    $str = 'foo   o';
    $str = preg_replace('/\s\s+/', '', $str);
    // This will be 'fooo' now
    echo $str;
    And thats just a modified example, taken directly from the php Manuel.

  4. #4
    Join Date
    Dec 2004
    Location
    Sydney
    Posts
    4,157

    Default

    Removing white space is not a solution. If the user searches for 2 part numbers (or any other phrase) it will fail.

    For example a search for,
    3KA 400 DKP

    would end up being a search for
    3KA400DKP
    which wouldn't match any part.

  5. #5
    Join Date
    Sep 2010
    Posts
    2

    Default

    Well lets say I wanted to try removing all white space from searches. where in the code would I alter it and what would I add?

  6. #6
    Join Date
    Dec 2004
    Location
    Sydney
    Posts
    4,157

    Default

    Are you using the PHP scripting option in Zoom, or are you using ASP, JS, CGI or .NET?

    I would think a better idea is to add all word variations of the part number to the meta data for each page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •