# Uax\_url\_email for email get unexpected search result

**URL:** <https://discuss.elastic.co/t/uax-url-email-for-email-get-unexpected-search-result/245041>\
**Category:** Elasticsearch\
**Created:** [August 14, 2020, 3:50pm UTC](https://discuss.elastic.co/t/uax-url-email-for-email-get-unexpected-search-result/245041 "2020-08-14T15:50:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jinlian\_Chen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jinlian_chen/32/44738_2.png) [@Jinlian\_Chen](https://discuss.elastic.co/u/Jinlian_Chen)\
**Post date:** [August 14, 2020, 3:50pm UTC](https://discuss.elastic.co/t/uax-url-email-for-email-get-unexpected-search-result/245041/1 "2020-08-14T15:50:58Z")

</div>

Elasticsearch version: 7.8.0  
Use uax\_url\_email and pattern\_capture to analyze emails, search email address get unexpected result.  
**Two email address:**  
hello-test [hello-world@gmail.com](mailto:hello-world@gmail.com)  
[hello-test-hello-world@gmail.com](mailto:hello-test-hello-world@gmail.com)

Search **hello-test** get "hello-test [hello-world@gmail.com](mailto:hello-world@gmail.com)", should return both docs.  
Search **hello-world** , nothing returns, should return both docs.

**Reproduce steps:**  
Put mapping:

```
PUT email
{
  "settings" : {
    "number_of_shards" : 1,
    "analysis": {
      "analyzer": {
        "email_analyzer": {
          "tokenizer": "uax_url_email",
          "filter": [
            "lowercase",
            "email",
            "remove_duplicates"
          ]
        },
        "search_email": {
          "tokenizer": "uax_url_email",
          "filter": [
            "lowercase"
          ]
        }
      },
      "filter": {
        "email": {
          "type": "pattern_capture",
          "preserve_original": "true",
          "patterns": [
            "([^@]+)",
            "(\\p{LD}+)",
            "@(.+)",
            "(@)"
          ]
        }
      }
    }
  },
  "mappings" : {
    "properties" : {
      "email" : { 
        "type" : "text",
        "analyzer": "email_analyzer"
      }
    }
  }
}

```

Put docs:

```
PUT email/_doc/1
{
  "email": "hello-test hello-world@gmail.com"
}

PUT email/_doc/2
{
  "email": "hello-test-hello-world@gmail.com"
}

```

Do search:

```
GET email/_search
{
  "query": {
    "match_phrase": {
      "email": "hello-test"
    }
  }
}

```

Result: Only return 1 doc: "hello-test [hello-world@gmail.com](mailto:hello-world@gmail.com)".  
Expected: Return all docs.

```
GET email/_search
{
  "query": {
    "match_phrase": {
      "email": "hello-world"
    }
  }
}

```

Result: No match doc returns.  
Expected: Return all docs

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2020, 3:51pm UTC](https://discuss.elastic.co/t/uax-url-email-for-email-get-unexpected-search-result/245041/2 "2020-09-11T15:51:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
