# Analyzer for numeric type of fields

**URL:** <https://discuss.elastic.co/t/analyzer-for-numeric-type-of-fields/8295>\
**Category:** Elasticsearch\
**Created:** [July 3, 2012, 6:56am UTC](https://discuss.elastic.co/t/analyzer-for-numeric-type-of-fields/8295 "2012-07-03T06:56:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [July 3, 2012, 6:56am UTC](https://discuss.elastic.co/t/analyzer-for-numeric-type-of-fields/8295/1 "2012-07-03T06:56:24Z")

</div>

I need to analyaze and tokenize the numeric fields like zip\_codes, which  
analyzer should I use??? currently I am using the standard analyzer, with  
with i can not search the partial zip\_codes,  
Expected is if i search for '45', then it should return all the zip\_codes  
starting with 45, but its returning result if i enter the full zip\_code and  
returns only single record.

Can anyone please guide me through this ???

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 3, 2012, 9:53am UTC](https://discuss.elastic.co/t/analyzer-for-numeric-type-of-fields/8295/2 "2012-07-03T09:53:48Z")

</div>

There isn't really a meaning for an analyzer on numeric values. They either  
indexed or not.

On Tue, Jul 3, 2012 at 8:56 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) wrote:

> I need to analyaze and tokenize the numeric fields like zip\_codes, which  
> analyzer should I use??? currently I am using the standard analyzer, with  
> with i can not search the partial zip\_codes,  
> Expected is if i search for '45', then it should return all the zip\_codes  
> starting with 45, but its returning result if i enter the full zip\_code and  
> returns only single record.
> 
> Can anyone please guide me through this ???

---

<div class="post-metadata">

**Author:** ![Jan\_Fiedler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jan_fiedler/32/2518_2.png) [@Jan\_Fiedler](https://discuss.elastic.co/u/Jan_Fiedler)\
**Post date:** [July 3, 2012, 11:55am UTC](https://discuss.elastic.co/t/analyzer-for-numeric-type-of-fields/8295/3 "2012-07-03T11:55:34Z")

</div>

If I understand the post correctly, the question is very specific to ZIP  
codes. They are numeric in may countries, but search requirements are  
usually very different (from a number). A zip code often has some semantic  
(like the first digit determining the state).

This said, I believe have to take a very careful look at your requirements  
and setup a special analyzer for the zip code field. By default, your field  
is detected as numeric and no analyzing process is applied. You want to  
change that and analyze as string with a special analyzer (depending on  
your requirements). I would look at an egde-ngram analyzer for starters.

---

<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, 2017, 3:21am UTC](https://discuss.elastic.co/t/analyzer-for-numeric-type-of-fields/8295/4 "2017-07-06T03:21:40Z")

</div>


