tjleigh
tjleigh

Reputation: 1144

searchContacts with phone number query is broken

Using the [searchContacts API method] (https://developers.google.com/people/api/rest/v1/people/searchContacts) used to support searching by telephone number - indeed this is called out in the documentation:

The query matches on a contact's names, nickNames, emailAddresses, phoneNumbers, and organizations fields that are from the CONTACT source.

It no longer returns results when using a phone number as the query. Is this deliberate, or a bug?

As per google people api search by phonenumbers I have tried a query of "canonical format without plus". I have also tried "canonical format with plus" and "exact number as stored".

Name query still works

https://people.googleapis.com/v1/people:searchContacts?readMask=names%2cphoneNumbers&query=Go Ogle&pageSize=30

returns

{
    "results": [
        {
            "person": {
                "resourceName": "people/c832768086350305259",
                "etag": "%EgcBAgsuNz0/GgECIgwxZGVYd20reHpEUT0=",
                "names": [
                    {
                        "metadata": {
                            "primary": true,
                            "source": {
                                "type": "CONTACT",
                                "id": "b8e96298f3117eb"
                            }
                        },
                        "displayName": "Go Ogle",
                        "familyName": "Ogle",
                        "givenName": "Go",
                        "displayNameLastFirst": "Ogle, Go",
                        "unstructuredName": "Go Ogle"
                    }
                ],
                "phoneNumbers": [
                    {
                        "metadata": {
                            "primary": true,
                            "source": {
                                "type": "CONTACT",
                                "id": "b8e96298f3117eb"
                            }
                        },
                        "value": "020 7031 3000",
                        "canonicalForm": "+442070313000"
                    }
                ]
            }
        }
    ]
}

Search by name works

Phone number query fails

https://people.googleapis.com/v1/people:searchContacts?readMask=names%2cphoneNumbers&query=442070313000&pageSize=30

returns

{}

Search by number fails

Upvotes: 1

Views: 637

Answers (2)

Oz Ben-David
Oz Ben-David

Reputation: 1657

The bug didn't went away although they say it was closed and verified In order to get the same functionality I had to be creative, the documentation says:

The query matches on a contact's names, nickNames, emailAddresses, phoneNumbers, and organizations fields that are from the CONTACT source.

The names, emailAddresses, phoneNumbers and organizations are important fields where you don't want to have garbage, but on my case at least the nickNames had no usage, so I simply add the phone number as nick name and the search works like charm.

Keep in mind that if you have many previous contacts you will have to write a script that will copy their phone number to the one of the nicknames fields.

Enjoy :)

Upvotes: 0

Daniel
Daniel

Reputation: 3725

The query function does indeed seem to be broken at the moment. My tests gave the same results and the question you linked shows that it clearly worked in the past.

I found a bug report on Google's issue tracker. A Googler already replied to it saying that they were able to reproduce it and filed an internal report. It's a matter of time until they fix it so you may want to keep track of that thread or post on it yourself to apply some pressure.

Upvotes: 0

Related Questions