Results 1 to 5 of 5

Thread: Search only works for first word in a field?

  1. #1
    mccon1 is offline Sugar Community Member
    Join Date
    Sep 2008
    Posts
    34

    Default Search only works for first word in a field?

    Hi,

    I am using the Sugar Community Edition Version 5.2.0i (Build 5757).

    When I have a company which is called for example "General Electric", it is possible to find it with the search query "General", but when I search for "Electric", I don't get any results. Can I change this somehow?

    regards,
    mccon1

  2. #2
    salesagility's Avatar
    salesagility is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    2,379

    Default Re: Search only works for first word in a field?

    The SugarCRM wild card is "%"

    So, search for "%electric"

    and it will find everthing with electric anywhere in the title

  3. #3
    mccon1 is offline Sugar Community Member
    Join Date
    Sep 2008
    Posts
    34

    Default Re: Search only works for first word in a field?

    Great, thanks!

    But I'd like to to have it integrated automatically with every search, so I edited the /modules/Home/UnifiedSearchAdvanced.php:

    In about line 134, right after
    Code:
    if(!empty($_REQUEST['query_string'])) {
    // MFH BUG 15404: Added support to trim off whitespace at the beginning and end of a search string
    $_REQUEST['query_string'] = trim($_REQUEST['query_string']);
    I added this line:
    Code:
    $_REQUEST['query_string'] = "%".$_REQUEST['query_string']; // Better wildcard search
    Now it works great if I use the global search box on the top right of every page. But if I use the search on the "Accounts" page, it isn't working. Where do I have to edit? I tried the /modules/Accounts/Account.php in about line 345, inside the "build_generic_where_clause" function, but it didn't work. Any suggestions?

    regards,
    mccon1
    Last edited by mccon1; 2009-09-30 at 09:35 AM.

  4. #4
    mccon1 is offline Sugar Community Member
    Join Date
    Sep 2008
    Posts
    34

    Default Re: Search only works for first word in a field?

    Any Ideas?

    regards,
    mccon1

  5. #5
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Search only works for first word in a field?

    Your approach is not upgrade safe, what means after upgrading your sugar these files can be overridden by a fixed one and your customization will be lost.
    You can consider creating a logic_hook after retrieve on Users module to add the "%" before the filters from Basic and Advanced Search.

    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2009-01-30, 11:38 PM
  2. Replies: 4
    Last Post: 2008-04-03, 10:00 AM
  3. Search no longer works after upgrade
    By sacramentojoe in forum Help
    Replies: 0
    Last Post: 2007-04-27, 05:04 PM
  4. Replies: 1
    Last Post: 2006-06-16, 03:35 AM

Tags for this Thread

Bookmarks

Posting Permissions

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