0
votes

I am using Azure Search in one of my projects and have a requirement to search case insensitive email addresses. E.g. emusk@gmail.com, EMusk@gmail.com, eMusk@gmail.com should all return the same result. I am using custom analyzer while creating an index (uax_url_email) https://docs.microsoft.com/en-in/rest/api/searchservice/custom-analyzers-in-azure-search#AnalyzerTable

Here is the portion of index

            [{
                "name": "Username",
                "type": "Edm.String",
                "searchable": true,
                "filterable": false,
                "sortable": false,
                "facetable": false,
                "analyzer": "email_analyzer"
            },              

        ],
        "analyzers": [
            {
                "name": "email_analyzer",
                "@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
                "tokenizer": "uax_url_email",
                "tokenFilters": ["lowercase"]
            }]

But the search is not working for Emusk@gmail.com. Can anyone please assist?

2

2 Answers

0
votes

I created an index with the same custom analyzer and got back the expected results with a case-insensitive match. I used a simple query - search=EMusk@gmail.com

Can you share the exact query being used?

You can also check if the field is getting analyzed and indexed properly. You can use the Analyze API for that purpose.

0
votes

So, here is the workaround that I have done. I had in my database email(s) containing uppercase letters like 'EMusk@gmail.com' I had a requirement to be able to search contains as well as full search which means: emusk@gmail.com, EMusk@gmail.com, musk@gmail.com should all return the result. So, I did the following things:

  1. Created a View and changed the email to Select LOWER(email) as email.
  2. So, my Azure Search index contains all lowercase emails.
  3. Then I am using /../&queryType=full to search the email. Example: /.EMUSK@gmail.com./&queryType=full.