# Match with forward slash and dash

**URL:** <https://discuss.elastic.co/t/match-with-forward-slash-and-dash/134121>\
**Category:** Elasticsearch\
**Created:** [June 1, 2018, 1:16am UTC](https://discuss.elastic.co/t/match-with-forward-slash-and-dash/134121 "2018-06-01T01:16:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhex900](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhex900/32/31753_2.png) [@zhex900](https://discuss.elastic.co/u/zhex900)\
**Post date:** [June 1, 2018, 1:16am UTC](https://discuss.elastic.co/t/match-with-forward-slash-and-dash/134121/1 "2018-06-01T01:16:59Z")

</div>

Hi,

I am trying for find the best way to index addresses.

The problem is that I get no match when input search have forward slash.

For example: I get no match for 1/3 example st.

I think the problem is the whitespace tokenizer produce this [1/3, example, st]. But I need [1,/,3,example,st]

How do I build a custom tokenizer to tokenize base up whitespace and forward slash?  
This is what I have.

```auto
    client.indices.create({
        index: 'address',
        body: {
            settings: {
                analysis: {
                    analyzer: {
                        address_analyzer: {
                            type: "custom",
                            tokenizer: "whitespace",
                            filter: [
                                "lowercase",
                                "asciifolding",
                                "synonym"
                            ]
                        }
                    },
                    filter: {
                        synonym: {
                            type: "synonym",
                            synonyms_path: "analysis/street_types.txt"
                        }
                    }
                }

            }
        }

```

```
        client.indices.putMapping({
            index: 'address',
            type: 'singleAddress',
            body: {
                properties: {
                    suggest: {
                        type: "completion",
                        analyzer: "address_analyzer",
                        preserve_separators: "false"
                    }
                }
            }
        });
```

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [June 8, 2018, 3:39pm UTC](https://discuss.elastic.co/t/match-with-forward-slash-and-dash/134121/2 "2018-06-08T15:39:11Z")

</div>

If you want really powerful, but potentially slow solution you can write your own [regex base tokenizer](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/analysis-pattern-tokenizer.html). But the simplest way would be to replace symbols like `/` with special tokens. For example:

```auto
POST _analyze
{
  "char_filter": [{
          "type": "mapping",
          "mappings": [
            "/ => -_slash_-"
          ]
        }],
  "tokenizer": "standard", 
  "text": "1/3 example st"
}

```

will produce `1`, `_slash_`, `3`, `example`, `st`

---

<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, 2018, 3:49pm UTC](https://discuss.elastic.co/t/match-with-forward-slash-and-dash/134121/3 "2018-07-06T15:49:50Z")

</div>

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