# Why word\_delimiter doesn's work on my index?

**URL:** <https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624>\
**Category:** Elasticsearch\
**Created:** [February 17, 2021, 10:37pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624 "2021-02-17T22:37:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andymov](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@andymov](https://discuss.elastic.co/u/andymov)\
**Post date:** [February 17, 2021, 10:37pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624/1 "2021-02-17T22:37:39Z")

</div>

Hi all!  
I need to search my products by codes like this one: "50-14Lx". I use word\_delimiter to tokenize "50-14Lx" to "50","14","Lx". But it doesn't work on my index.

Index:

```auto
    PUT /products
    {
      "settings": {
        "analysis": {
          "analyzer": {
            "my_analyzer": {
              "tokenizer": "whitespace",
              "filter": ["word_delimiter"]
            }
          }
        }
      }
    }

```

Analyze:

```auto
    GET /_analyze
    {
      "tokenizer": "whitespace",
      "filter": ["word_delimiter_graph"],
      "text": "50-14Lx"
    }

```

It's OK, as expected returns: "50", "14", "Lx"

But my index returns "wrong" results "50", "14Lx":

```auto
    GET /products/_analyze
    {
      "explain": true, 
      "text": "50-14Lx"
    }

```

Question: why "14Lx" was not split inside my index ?

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [February 17, 2021, 10:47pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624/2 "2021-02-17T22:47:34Z")

</div>

Try this

```auto
GET /products/_analyze
{
  "explain": true,
  "analyzer": "my_analyzer",
  "text": "50-14Lx"
}

```

---

<div class="post-metadata">

**Author:** ![andymov](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@andymov](https://discuss.elastic.co/u/andymov)\
**Post date:** [February 17, 2021, 11:16pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624/3 "2021-02-17T23:16:33Z")

</div>

Yes, this variant returns expacted results. All three tokens.

But why searching doesn't work?

```auto
POST /_bulk
{"index":{"_index":"products","_id":"1"}}
{"name": "50-14Lx"}
{"index":{"_index":"products","_id":"2"}}
{"name": "60-33Xp"}

```

Try to search by part of product name "14":

```auto
GET /products/_search
{
  "query": {
    "match": {
      "name": "14"
    }
  },
  "_source": ["id", "name"]
}

```

returns empty set...

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [February 17, 2021, 11:18pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624/4 "2021-02-17T23:18:52Z")

</div>

You have to define a mpping to your index and use the custom analyzer for field name

```auto
PUT /products
{
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "analyzer": "my_analyzer",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        }
      }
    }
  },
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0,
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "whitespace",
          "filter": [
            "word_delimiter"
          ]
        }
      }
    }
  }
}

POST /_bulk
{"index":{"_index":"products","_id":"1"}}
{"name": "50-14Lx"}
{"index":{"_index":"products","_id":"2"}}
{"name": "60-33Xp"}

GET /products/_search
{
  "query": {
    "match": {
      "name": "14"
    }
  },
  "_source": [
    "id",
    "name"
  ]
}

```

---

<div class="post-metadata">

**Author:** ![andymov](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@andymov](https://discuss.elastic.co/u/andymov)\
**Post date:** [February 17, 2021, 11:28pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624/5 "2021-02-17T23:28:21Z")

</div>

Thank you!

---

<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:** [March 17, 2021, 11:29pm UTC](https://discuss.elastic.co/t/why-word-delimiter-doesns-work-on-my-index/264624/6 "2021-03-17T23:29:05Z")

</div>

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