# How to configure a pattern\_capture on a specific token type?

**URL:** <https://discuss.elastic.co/t/how-to-configure-a-pattern-capture-on-a-specific-token-type/19603>\
**Category:** Elasticsearch\
**Created:** [September 3, 2014, 7:06pm UTC](https://discuss.elastic.co/t/how-to-configure-a-pattern-capture-on-a-specific-token-type/19603 "2014-09-03T19:06:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephanie\_Rochelemag](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@Stephanie\_Rochelemag](https://discuss.elastic.co/u/Stephanie_Rochelemag)\
**Post date:** [September 3, 2014, 7:06pm UTC](https://discuss.elastic.co/t/how-to-configure-a-pattern-capture-on-a-specific-token-type/19603/1 "2014-09-03T19:06:40Z")

</div>

Hi,

I have setup a custom analyzer with uax\_url\_email as tokenizer. I have  
added a pattern\_capture filter to index the emails.  
Now I would like that the urls be searchable and I would like to do the  
same but executing the filter with a condition: either if the token starts  
with http or on the specific type of the token URL.  
I don;t know if it is possible and if say, please let me know how to  
achieve it.

Thanks in advance!  
Stephanie

```
    analysis: {
      filter: {
        email: {
           type: "pattern_capture",
           preserve_original: 1,
           patterns: [
              "([\\w\\-\\+\\.]+?)(?:[\\.\\-_](\\w+))?@([\\w\\-]+)\."
           ]
        },
        url: {
           type: "pattern_capture",
           token_type: "URL",
           preserve_original: 1,
           patterns: [
              "(?:(\w+)(?:.|\/))"
           ]
        }
      },
      analyzer: {
        default: {
          type: 'custom',
          char_filter: [
            'html_strip'
          ],
          tokenizer: 'uax_url_email',
          filter: [
            'email',
            'url',
            'asciifolding',
            'lowercase'
          ]
        }
      }
    }

```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5587b5a1-3cd4-4b9d-a6af-02f7daa237d2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5587b5a1-3cd4-4b9d-a6af-02f7daa237d2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:04am UTC](https://discuss.elastic.co/t/how-to-configure-a-pattern-capture-on-a-specific-token-type/19603/2 "2017-07-06T01:04:34Z")

</div>

Closed on July 6, 2017, 1:04am UTC


