Valeri
Valeri

Reputation: 1142

Elastic Search query for email

I am trying to implement email search with ElasticSearch.
Here are the example documents.

{
  ...  
  "email": "[email protected]" 
},
{
  ...
  "email": "[email protected]"
}

So when I use the match query: { "match": { "email": "[email protected]" } }
I get both of "[email protected]"and "[email protected]" but the result must be only "[email protected]".

I think it is because of @ character.
Any good solution to resolve this issue?

Upvotes: 2

Views: 2539

Answers (2)

Boston Kenne
Boston Kenne

Reputation: 818

Use this to make your request 👍

GET my_index/_search
{
    "query": {
        "match_phrase_prefix" : {
            "email": "[email protected]"
        }
    }
}

You will have the expecting result

Upvotes: 0

KayV
KayV

Reputation: 13855

You need to use the Email Tokenizer as specified here:

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-uaxurlemail-tokenizer.html

Upvotes: 1

Related Questions