APIs & Integrations

amitc005
Mitglied

Partial Search

Is there any way we can search for a property partially? 

like the content like '%SAM%'?

0 Upvotes
6 Antworten
jimig
Teilnehmer/-in

Partial Search

It get's weirder, consider the following search:

 

{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "phone",
          "operator": "CONTAINS_TOKEN",
          "value": "7608915463"
        }
      ]
    },
    {
      "filters": [
        {
          "propertyName": "mobilephone",
          "operator": "CONTAINS_TOKEN",
          "value": "7608915463"
        }
      ]
    }
  ],
  "sorts": [
    {
      "propertyName": "modifieddate",
      "direction": "DESCENDING"
    }
  ],
  "properties": [
    "email",
    "firstname",
    "lastname",
    "country",
    "phone",
    "mobilephone",
    "jobtitle",
    "hubspot_owner_id",
    "associatedcompanyid",
    "photo"
  ],
  "limit": "25"
}

 

If a contact has a phone number of +17608915463 this fails to find it. Yet if we search for "17608915463" it succeeds. Why?

0 Upvotes
jimig
Teilnehmer/-in

Partial Search

@Derek_Gervaiswe are also seeing the searches fail with CONTAINS_TOKEN.

 

For example, if we apply a series of OR queries like so:

 

 

"filterGroups": [
    {
      "filters": [
        {
          "propertyName": "mobilephone",
          "operator": "CONTAINS_TOKEN",
          "value": "7608915463"
        }
      ]
    },
    {
      "filters": [
        {
          "propertyName": "phone",
          "operator": "CONTAINS_TOKEN",
          "value": "7608915463"
        }
      ]
    },
    {
      "filters": [
        {
          "propertyName": "hs_calculated_phone_number",
          "operator": "CONTAINS_TOKEN",
          "value": "7608915463"
        }
      ]
    }
  ],

 

 

and the contact phone is +17608915463 - we get no results.

0 Upvotes
Derek_Gervais
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

Partial Search

Hey @amitc005 ,

 

You should be able to use the new CRM Search API for this purpose: https://developers.hubspot.com/docs/api/crm/search

0 Upvotes
amitc005
Mitglied

Partial Search

I checked and current we have query which searches some properties of the object, for eg, for tickets 

"hs_ticket_category",

"hs_ticket_id",

"subject",

"hs_pipeline_stage",

"content"

But I want something search for a particular property. 

0 Upvotes
Derek_Gervais
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

Partial Search

Hey @amitc005 ,

 

The default searchable properties you're describing is the set of properties we look at for query searches. For example, if you made the following request:

 

curl https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "query": "x"
  }'

HubSpot would return contact records where x appeared in any of the default searchable properties for contacts (i.e. firstname, hs_additional_emails, phone, hs_object_id, hs_searchable_calculated_phone_number, company, email, lastname). 

 

But any property is searchable using Filters, described in the section right above Search. If you wanted to get all contact records where exampleCustomProperty contains test, you could do something like this:

curl https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "exampleCustomProperty",
            "operator": "CONTAINS_TOKEN",
            "value": "test"
          }
        ]
      }
    ]
  }'

 

0 Upvotes
hemal108
Mitglied

Partial Search

V3 CRM search api is not woking, for example if contact property firstname have value "Hemal" and if i try to search with "hem", API is not giving any results.

0 Upvotes