Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Loosen Search Query

    Hi All,

    I thought I had already posted this issue, but cannot seem to find the thread so my apologies if this is a duplicate...

    My client would like to 'loosen' the search terms so that when a user runs a 'Product Search' using any of the following:

    billet grille
    billetgrille
    redbilletgrille nissan

    It would basically return any product with 'Billet Grille' in the title, regardless of spacing. I'm pretty sure adjusting the query to something such as: LIKE %$search_keywords% would do the trick, but I'm not sure where to make the change. Can anyone point me in the right direction, or perhaps offer a better solution?

  2. #2
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: Loosen Search Query

    Quote Originally Posted by DiZZ View Post
    I'm pretty sure adjusting the query to something such as: LIKE %$search_keywords% would do the trick, but I'm not sure where to make the change. Can anyone point me in the right direction, or perhaps offer a better solution?
    It won't- what you need to do is a multi query against various lengths of your search string or do a remove of all whitespace in the search term and the field that is being searched.

    I think what is needed is a 'loose search' contrib- returning each search with a percentage confidence level (and sorted by)
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  3. #3
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Loosen Search Query

    Do you know which file contains the search query?

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Loosen Search Query

    With the OR connector used on the search, you will find:
    billet grille
    billet
    grille

    brings up all three ...

    You can also utilize meta tags keywords and description for building in more combinations ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Loosen Search Query

    Hi Dizz,

    I think you are looking for this file:
    includes\modules\pages\advanced_search_result\header_php.php

    Some time ago I added this as a quick hack:
    Code:
    $_GET['keyword'] = trim($_GET['keyword']);
    (somewhere at the top of the file)
    But I am not really satisfied and will probably make other adjustments.

    The part of the file you are looking for probably is:
    Code:
            $where_str .= "(pd.products_name LIKE '%:keywords%'
                                             OR p.products_model
                                             LIKE '%:keywords%'
                                             OR m.manufacturers_name
                                             LIKE '%:keywords%'";
    If you find your solution I hope you will post it here

  6. #6
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: Loosen Search Query

    Thinking about this further, SOUNDEX could possibly be a winner. Especially as MySQL has a SOUNDS LIKE expression. Run a SELECT for description SOUNDS LIKE search_clue OR search_clue SOUNDS LIKE description
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  7. #7
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Loosen Search Query

    Quote Originally Posted by hem View Post
    Thinking about this further, SOUNDEX could possibly be a winner. Especially as MySQL has a SOUNDS LIKE expression. Run a SELECT for description SOUNDS LIKE search_clue OR search_clue SOUNDS LIKE description
    There could be some big challenges with multi-lingual sites when using that approach. Something to keep in mind as you research further.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: Loosen Search Query

    Quote Originally Posted by DrByte View Post
    There could be some big challenges with multi-lingual sites when using that approach. Something to keep in mind as you research further.
    That's true- SOUNDEX only works on English. Plus it won't handle multi-byte either.
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  9. #9
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Loosen Search Query

    Quote Originally Posted by paulm View Post
    Some time ago I added this as a quick hack:
    Code:
    $_GET['keyword'] = trim($_GET['keyword']);
    (somewhere at the top of the file)
    But I am not really satisfied and will probably make other adjustments.
    Sorry I made a mistake, this will not help for any spacing issues, it only helps to for several other characters that the customer may enter, like "-" for example.
    (which may not seem logical at first when you look at the code, which explains why I mixed up things myself too, must add a comment to this line ... )

  10. #10
    Join Date
    Oct 2006
    Posts
    170
    Plugin Contributions
    0

    Default Re: Loosen Search Query

    Ah thanks anyway Paul - I guess the '%' in '%$keyword%' only accounts for actual characters, not spaces?

    Honestly I think this is really minor, but my client is stuck on the idea that all users are idiots and that by 'loosening' the search query the site will become more idiot-proof.

    I'd appreciate any rebuttals if you have them - LOL!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Search - including or ignoring "and" as first keyword in search query
    By nikerymis in forum General Questions
    Replies: 0
    Last Post: 27 Jan 2014, 08:44 PM
  2. Replies: 1
    Last Post: 25 Jan 2011, 02:05 PM
  3. Customize admin customer search query: search alt emails, too?
    By Matt008 in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 15 Apr 2010, 01:10 AM
  4. Maintaining the user's search query in the advanced search box?
    By arniesbarmyarmy in forum General Questions
    Replies: 0
    Last Post: 26 Feb 2010, 01:27 PM

Posting Permissions

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