How to search for people by different phone number formats

Manuel 25 Reputation points
2024-02-08T15:35:16.8966667+00:00

We use the Microsoft Graph search endpoint (https://graph.microsoft.com/v1.0/search/query) to search people by phone number, e.g.:

// 
{
    "requests": [
        {
            "entityTypes": [
                "person"
            ],
            "query": {
                "queryString": "+41791112233"
            }
        }
    ]
}

a) How can we search people by different phone number formats? KQL doesn't seem to work in that case:

// 
{
    "requests": [
        {
            "entityTypes": [
                "person"
            ],
            "query": {
                "queryString": "+41791112233 OR 41791112233 OR +41 79 111 22 33"
            }
        }
    ]
}

b) What's the format logic behind the scenes for people search? Does the endpoint use a specific format? I have a personal contact with the following business phone number: +41 791112233 I get obscure results when I search with different formats:

  • +41791112233 (OK)
  • 41791112233 (NOK)
  • 0791112233 (OK)
  • 079 111 22 33 (NOK)
  • 791112233 (OK)
  • 41 791112233 (NOK)
  • 41 79 111 22 33 (NOK)
  • +41 79 111 22 33 (OK)
Microsoft Security | Microsoft Graph
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Deepanshu Sharma 500 Reputation points Microsoft External Staff
    2024-02-12T03:36:04.6633333+00:00

    Hi Manuel, you can use of $filter with the or operators on properties. GET~/users?$filter=startswith(displayName,'mary') or startswith(givenName,'mary') or startswith(surname,'mary') or startswith(mail,'mary') or startswith(userPrincipalName,'mary') https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http#examples-using-the-filter-query-operator https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http#query-scenarios-that-require-advanced-query-capabilities


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.