Content Search Query

Karun Khanna 46 Reputation points

Need to search for keywords in Office 365 content search, please help with the query...i need to find emails with certain keywords but it shouldn't have few keywords like

Should be present
King Crown
King Street 12

Should not be present
Street Dancer
RET 26

Is the below query correct under keyword search? Please advice with the correct one.

Crown OR King Crown OR King Street 12 NOT Queen NOT Street Dancer NOT Ret 26

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,060 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 91,361 Reputation points MVP

    The second example is closer, but you need to adjust it a bit. If you need to exclude ANY of the second group of keywords, you should group them together via AND statements. Using OR will return results where only one of those is missing. And if you do it without grouping like in the first example, you need to group the first set of keywords.

    0 comments No comments

  2. Lucas Liu-MSFT 6,156 Reputation points

    Hi @Karun Khanna ,
    Your second plan is better, it should be noted that if you use "OR" to connect the second group of keywords, as long as the email contains any keyword, it will not be displayed in the results. If you use the "AND" connection, then only if the email contains all keywords at the same time, it will not be displayed in the results. As my test results, if an email contains both keywords that need to exist and keywords that do not need to exist, the email will not appear in the search results.
    The screenshot below is test in my lab environment, tested the results returned by using "OR" and "AND" to connect the second set of keywords, which hope can help you understand better.
    The mail in my mailbox.
    Using "OR"
    Using "AND"


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.