# Edge Ngram not working with digits

**URL:** https://discuss.elastic.co/t/edge-ngram-not-working-with-digits/89387
**Category:** Elasticsearch
**Created:** [June 14, 2017, 1:54pm UTC](https://discuss.elastic.co/t/edge-ngram-not-working-with-digits/89387 "2017-06-14T13:54:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![munotshubham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munotshubham/32/22663_2.png) [@munotshubham](https://discuss.elastic.co/u/munotshubham)
#### Post date: [June 14, 2017, 1:54pm UTC](https://discuss.elastic.co/t/edge-ngram-not-working-with-digits/89387/1 "2017-06-14T13:54:10Z")

</div>

Hi,

So I'm trying to build search-as-you-type and this is my mapping:

```
PUT patients
{
  "settings": {
    "analysis": {
      "analyzer": {
        "autocomplete": {
          "tokenizer": "autocomplete",
          "filter": [
            "lowercase"
          ]
        },
        "autocomplete_search": {
          "tokenizer": "lowercase"
        }
      },
      "tokenizer": {
        "autocomplete": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 10,
          "token_chars": [
            "letter","digit","symbol","whitespace"
          ]
        }
      }
    }
  },
  "mappings": {
    "db": {
      "properties": {
        "FirstName": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "autocomplete_search"
        },
        "LastName": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "autocomplete_search"
        },
        "PreferredName": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "autocomplete_search"
        },
        "DateOfBirth": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "autocomplete_search"
        },
        "PMRecordNumber": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "autocomplete_search"
        }
      }
    }
  }
}

```

PMRecordnumber is alphanumeric string, eg: "PH100304", "PH105302" etc.  
So when I'm trying to search this:

```
 GET patients/_search
{
  "explain": true, 
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "query": "PH1003",
            "fields": ["FirstName", "LastName", "DateOfBirth", "PMRecordNumber"]
            , "type": "cross_fields"
          }
        }
      ]
    }
  }
}

```

So it is giving results with last name = "Phy" and it is not scoring based on PMRecordnumber.

I believe the "lowercase" tokenizer is dropping the digits out, so how am is supposed to go about this?

---

<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 12, 2017, 1:54pm UTC](https://discuss.elastic.co/t/edge-ngram-not-working-with-digits/89387/2 "2017-07-12T13:54:20Z")

</div>

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