CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • search API - not what I expected
Pages: [1]

Author Topic: search API - not what I expected  (Read 1102 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
search API - not what I expected
October 26, 2009, 02:42:14 am
Hello,

I have found that the contact search API is returning more results than I expected. If I search for an organisation called 'my org' it returns 'my cat', 'my beer', 'my org' and 'another org'.

This is the code I have been running:

if (module_exists('civicrm')) {
  civicrm_initialize(TRUE);
  require_once 'api/v2/Contact.php';

            $params = array(
                    'return' => 'id',
                    'sort_name'=>"my org",

                    'contact_type'=> 'Organization'
            );
         //establish the contact ID of the selected Current Employer
print ("params<br>");
print_r ($params);
            $apiSearch=(array_values( civicrm_contact_search($params)));
print ("api<br>");
print_r ($apiSearch);

I tried display name which was the same and organization_name which only found 'my org' but I do have two organisations in my local install database with no organization_name - I'm not sure why but perhaps they were created in an earlier version of CiviCRM.
    
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: search API - not what I expected
October 26, 2009, 03:28:03 am
Hi,

Yes, common problem with the UI search. it's searching with an OR between the words. There is a patch floating in the forums that does an AND, works better when you have 10k contacts, might work better no matter what.

If you don't find it, ping and I'll try to find it and regenerate a patch.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • search API - not what I expected

This forum was archived on 2017-11-26.