v3 search not working with two filters

enlai
Member

Hi I'm trying to use the v3 API to do a match on the first and last name of a contact. Using the first name only in the filter works. Adding the second filter (for AND condition) using the last name gives no results.

 

This works:

 

{
  "properties": [
    "firstname",
    "lastname",
    "email",
    "phone",
    "mobilephone",
    "company",
    "lifecyclestage",
    "jobtitle"
  ],
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "firstname",
          "operator": "CONTAINS_TOKEN",
          "value": "erica"
        }
      ]
    }
  ]
}

 

Result:

 

                                    [id] => 4551
                                    [properties] => Array
                                        (
                                            [company] => Spam
                                            [createdate] => 2020-08-06T18:38:13.469Z
                                            [email] => erica@spam.com
                                            [firstname] => Erica
                                            [hs_object_id] => 4551
                                            [jobtitle] =>
                                            [lastmodifieddate] => 2020-08-06T18:38:21.159Z
                                            [lastname] => Spammer7
                                            [lifecyclestage] => lead
                                            [mobilephone] =>
                                            [phone] => +1xxxxxxxxxx
                                        )

                                    [createdAt] => 2020-08-06T18:38:13.469Z
                                    [updatedAt] => 2020-08-06T18:38:21.159Z
                                    [archived] =>
                                )

 

When I add the last name filter, I get no results back.

{
  "properties": [
    "firstname",
    "lastname",
    "email",
    "phone",
    "mobilephone",
    "company",
    "lifecyclestage",
    "jobtitle"
  ],
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "firstname",
          "operator": "CONTAINS_TOKEN",
          "value": "erica"
        },
        {
          "propertyName": "lastname",
          "operator": "CONTAINS_TOKEN",
          "value": "spamm"
        }
      ]
    }
  ]
}

 

Results:

 

        (
            [status] => 1
            [message] =>
            [response] => Array
                (
                    [total] => 0
                    [results] => Array
                        (
                        )

                )

        )

 

Am I doing something wrong? 

Thanks! 

0 Upvotes
2 Replies 2
enlai
Member

I realize that I'm using the full first name in my initial search. I assume that CONTAINS_TOKEN means my search term will match anywhere in the string, correct? Or do I need to add wildcards on each side of my search term explicitly? 

 

e.g. %xxx% or *xxx*

0 Upvotes
ErikV
Participant

I had a similar question, and what I figured out was that it matches WHOLE tokens only. So if you are searching, for example, the email address field, then it tries to match each of the parts between the special characters '@' and '.' with the token that you supplied.

 

Search term 'com' would find 'mymail@gmail.com' ... but it won't find 'command@space.org'

 

Or to put it differently, if I want to find the following email addres: 'bears@forest.net'

... I would have to search for either 'bears' or 'forest' or 'net' to find it. If I use 'fore' or just 'bear' I won't get the result.