# Indexing and searching strings with periods (".")

**URL:** https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919
**Category:** Elasticsearch
**Created:** [February 7, 2018, 8:15pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919 "2018-02-07T20:15:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![rsk](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rsk](https://discuss.elastic.co/u/rsk)
#### Post date: [February 7, 2018, 8:15pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919/1 "2018-02-07T20:15:53Z")

</div>

How can I set up indexing and searching to disregard periods when matching strings?

For example, if I search for USA I want USA and U.S.A to be returned. Likewise, U.S.A. should return both U.S.A. and USA.

I know I can use synonyms for this but I'd prefer not to have to specify the synonyms ahead of time.

Thanks!

---

<div class="post-metadata">

### Author: ![moy2010](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/moy2010/32/22403_2.png) [@moy2010](https://discuss.elastic.co/u/moy2010)
#### Post date: [February 7, 2018, 9:19pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919/2 "2018-02-07T21:19:40Z")

</div>

You could use a [char filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-mapping-charfilter.html) and map the dot to be analyzed as an empty string, and use this char filter for both your index and search analyzer.

---

<div class="post-metadata">

### Author: ![moy2010](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/moy2010/32/22403_2.png) [@moy2010](https://discuss.elastic.co/u/moy2010)
#### Post date: [February 7, 2018, 9:22pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919/3 "2018-02-07T21:22:28Z")

</div>

Another solution would be to use the [word delimiter token filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-word-delimiter-tokenfilter.html) and catenate everything or only words, so that both U.S.A. and USA are valid tokens appearing on your index.

---

<div class="post-metadata">

### Author: ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)
#### Post date: [February 7, 2018, 9:30pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919/4 "2018-02-07T21:30:42Z")

</div>

You could try defyning a mapping char filter analyzer ([https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-mapping-charfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-mapping-charfilter.html)) or a pattern replace char filter analyzer: [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-replace-charfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-replace-charfilter.html).

```
PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "char_filter": [
            "my_char_filter"
          ]
        }
      },
      "char_filter": {
        "my_char_filter": {
          "type": "pattern_replace",
          "pattern": "\\.",
          "replacement": ""
        }
      }
    }
  }
}

POST my_index/_analyze
{
  "analyzer": "my_analyzer",
  "text": "u.s.a."
}
```

---

<div class="post-metadata">

### Author: ![rsk](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rsk](https://discuss.elastic.co/u/rsk)
#### Post date: [February 17, 2018, 10:22pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919/5 "2018-02-17T22:22:53Z")

</div>

Thank you. The word delimiter token filter does the job!

---

<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, 2018, 10:22pm UTC](https://discuss.elastic.co/t/indexing-and-searching-strings-with-periods/118919/6 "2018-03-17T22:22:57Z")

</div>

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