Graph API - use $search with multiple parameters

Donald Kim 1 Reputation point
2021-03-04T09:47:12.47+00:00

Hello!

I want to use $search (https://learn.microsoft.com/en-us/graph/query-parameters#search-parameter) with multiple parameters with OR statement, like this:

https://graph.microsoft.com/v1.0/me/messages?$search="hello" or "good day"

But I can't find something helpful in documentation.

May be there is some way to use this with OR statement?

Microsoft Graph Search API
Microsoft Graph Search API
A Microsoft API that searches for information in email messages, returns messages ranked by relevance, and renders a dedicated search experience.
174 questions
Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
796 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Dev 106 Reputation points
    2021-03-31T11:31:35.67+00:00

    You can pass the OR statement between the condition followed with the "statement1" OR "statement2 and make sure you have space between statement1<space>OR<space>statement2"

    For my case below is the sample that worked.

    https://graph.microsoft.com/beta/users?$search=%22jobTitle:u%22%20OR%20%22displayName:u%22

    For your case below should work

    https://graph.microsoft.com/v1.0/me/messages?$search="hello" OR "good day"

    Note : OR should be in capital.
    Thanks

    0 comments No comments

  2. Danstan Onyango 3,241 Reputation points
    2021-07-07T07:49:20.783+00:00

    For this kind of search, you should use the search API. Here is a example to search your files.

    POST https://graph.microsoft.com/v1.0/search/query  
          
    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "message"  
                ],  
                "query": {  
                    "queryString": "hello OR good day"  
                }  
            }  
        ]  
    }  
    
    0 comments No comments