# How can I put together a case-insensitive analyzer for tokens?

**URL:** <https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471>\
**Category:** Elasticsearch\
**Created:** [November 19, 2013, 5:16pm UTC](https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471 "2013-11-19T17:16:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [November 19, 2013, 5:16pm UTC](https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471/1 "2013-11-19T17:16:00Z")

</div>

My input tokens are like:  
abcd-123  
ABCD-123  
abCD-123

Right now I don't analyze them at all but that comes back to bite me if  
someone searches for them with the wrong case-sensitivity.

So I want to use or put together an analyzer that doesn't break these  
tokens apart but still allows them to be analyzed for case-insensitive  
search later. Any suggestions?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [November 19, 2013, 5:25pm UTC](https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471/2 "2013-11-19T17:25:56Z")

</div>

Configure a custom analyzer with the keyword tokenizer and lowercase token  
filter.

index :  
analysis :  
analyzer :  
lowerKeyword:  
type : custom  
tokenizer : keyword  
filter : [lowercase]

Thanks,  
Matt Weber

On Tue, Nov 19, 2013 at 9:16 AM, pulkitsinghal [pulkitsinghal@gmail.com](mailto:pulkitsinghal@gmail.com)wrote:

> My input tokens are like:  
> abcd-123  
> ABCD-123  
> abCD-123
> 
> Right now I don't analyze them at all but that comes back to bite me if  
> someone searches for them with the wrong case-sensitivity.
> 
> So I want to use or put together an analyzer that doesn't break these  
> tokens apart but still allows them to be analyzed for case-insensitive  
> search later. Any suggestions?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [November 19, 2013, 9:06pm UTC](https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471/3 "2013-11-19T21:06:56Z")

</div>

> index :  
> analysis :  
> analyzer :  
> lowerKeyword:  
> type : custom  
> tokenizer : keyword  
> filter : [lowercase]

Thanks a lot Matt!

Can anyone additionally tell me how to set this up programmatically via  
java?  
I don't know how to set a name (like lowerKeyword) for the analyzer ...  
here's what I have so far:  
indexerSettings.put("analysis.analyzer.events.type", "custom");  
indexerSettings.put("analysis.analyzer.events.tokenizer", "keyword");  
indexerSettings.put("analysis.analyzer.events.filter", "lowercase");

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [November 19, 2013, 11:48pm UTC](https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471/4 "2013-11-19T23:48:58Z")

</div>

Cihat Keser, over from Jest [https://github.com/searchbox-io/Jest](https://github.com/searchbox-io/Jest), pointed  
out that the string "events" in the code block below is what constitutes as  
the name for an analyzer:

```
 indexerSettings.put("analysis.analyzer.events.type", "custom");

```

> ```
> indexerSettings.put("analysis.analyzer.events.tokenizer", "keyword");
> indexerSettings.put("analysis.analyzer.events.filter", "lowercase");
> 
> ```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:06am UTC](https://discuss.elastic.co/t/how-can-i-put-together-a-case-insensitive-analyzer-for-tokens/14471/5 "2017-07-06T02:06:08Z")

</div>


