# How to custom analyzer to define an analyzer that emits one term per letter

**URL:** <https://discuss.elastic.co/t/how-to-custom-analyzer-to-define-an-analyzer-that-emits-one-term-per-letter/39298>\
**Category:** Elasticsearch\
**Created:** [January 15, 2016, 3:17am UTC](https://discuss.elastic.co/t/how-to-custom-analyzer-to-define-an-analyzer-that-emits-one-term-per-letter/39298 "2016-01-15T03:17:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [January 15, 2016, 3:17am UTC](https://discuss.elastic.co/t/how-to-custom-analyzer-to-define-an-analyzer-that-emits-one-term-per-letter/39298/1 "2016-01-15T03:17:16Z")

</div>

Hi . Im newbie in elasticsearch And I have some question . Please help me 🙂

Im trying input data from postgres database into elasticsearch. Now i want spaces with each letter before input it into elasticsearch server.

Example : i have three field like this:  
id....code....name  
1.....10...........John  
2......19.........Lina

i want spaces in someone data in some field name . It look like John --\> J o h n . Lina ---\> L i n a  
Anybody have anyidea about how to do it in analyzer elasticsearch?  
im using elasticsearch 1.7.3  
Thanks for your help :x :x

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 15, 2016, 7:44am UTC](https://discuss.elastic.co/t/how-to-custom-analyzer-to-define-an-analyzer-that-emits-one-term-per-letter/39298/2 "2016-01-15T07:44:45Z")

</div>

I'm unsure I understood what you want to do.

> [@NgocPham](#):
>
> Now i want spaces with each letter before input it into elasticsearch server.

If it's **before** , so that `_source` will reflect those changes, you have to do that **before** elasticsearch which means in your client or in logstash if you are using logstash.

If you want that a field `john` become `j`,`o`,`h`,`n` at index time, then you can look at the [ngram tokenizer](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/analysis-ngram-tokenizer.html) and set `min_gram` and `max_gram` to 1.

Not sure that I understood the use case though.

---

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [January 15, 2016, 9:44am UTC](https://discuss.elastic.co/t/how-to-custom-analyzer-to-define-an-analyzer-that-emits-one-term-per-letter/39298/3 "2016-01-15T09:44:28Z")

</div>

thanks for your help. I will try with ngram tokenizer

---

<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 5, 2017, 11:24pm UTC](https://discuss.elastic.co/t/how-to-custom-analyzer-to-define-an-analyzer-that-emits-one-term-per-letter/39298/4 "2017-07-05T23:24:13Z")

</div>


