Content Search Query

Karun Khanna 46 Reputation points
2020-09-23T11:48:48.7+00:00

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
Crown
King Crown
King Street 12

Should not be present
Queen
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,195 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 95,666 Reputation points MVP
    2020-09-23T14:54:19.667+00:00

    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,161 Reputation points
    2020-09-24T05:53:03.593+00:00

    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.
    27928-11.png
    Using "OR"
    27930-2222.png
    Using "AND"
    27867-555555.png

    ----------

    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.