Search code examples
azureazure-cognitive-search

Azure Search returning incorrect results


I'm using Azure Search to query a data set relating to documents. I'm querying the data to fetch the documents that are owned by a particular user based on their email address.

The data set within the index contains a column called UploadedBy which represents the user who uploaded the document.

My query looks like this.

[email protected]&searchFields=UploadedByEmail

The search query speficies the value to look for and the column in which to search for it. However, I'm getting results returned that do not match this search criteria i.e. where the email address contains a different email address.

How do I prevent these from being returned? Am I missing something from my seach?


Solution

  • probably you're getting results that match:

    [email protected]

    and

    *@mycompany.com

    this is not wrong, it's the expected behavior since an email has '.' and it's considered a stop word. If you want the exact match, you should use search="[email protected]", escape your '.' or replace them to another char that is not a stop word.

    As another option, use a custom analyzer to avoid breaking on "." for emails.