# Customized analyzers behave

**URL:** <https://discuss.elastic.co/t/customized-analyzers-behave/22146>\
**Category:** Elasticsearch\
**Created:** [February 13, 2015, 5:16am UTC](https://discuss.elastic.co/t/customized-analyzers-behave/22146 "2015-02-13T05:16:58Z")\
**Posts on this page:** 3\
**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:** [February 13, 2015, 5:16am UTC](https://discuss.elastic.co/t/customized-analyzers-behave/22146/1 "2015-02-13T05:16:58Z")

</div>

Hi All,

I am trying to write down a custom analyzer like as follows :

"analysis": {

```
   "tokenizer": {

     "my_edge_ngram_tokenizer": {

       "type": "edgeNGram",

       "min_gram": "1",

       "max_gram": "20",

       "token_chars": []

     }

   },

   "filter": {

     "ys_word_delimiter": {

       "type": "word_delimiter",

       "stem_english_possessive": "False"

     }

   },

   "analyzer": {

     "ys_search_analyzer": {

       "type": "custom",

       "tokenizer": "my_edge_ngram_tokenizer",

       "filter": [

         "ys_word_delimiter",

         "lowercase"

       ]

     }

   }

 }

```

Now I need to have a behave for analyzer that if i search for title as\*  
"ca,usa" OR "ca, usa"\*, both should be searchable using this analyzer. But  
right now its searching only what has been saved, So if the title is saved  
with space then space is searchable and if title is saved without space,  
its searchable without space.

So I tried to add "trim" filter in the filter list. Expecting, after  
tokenizer, the token filter will run on the token generated, so " usa" will  
be convered to "usa" token. so whether the title is without space or with  
space, the read and write time will finally be changed into a trimmed token  
after bypassing this analyzer.

If I am mistaken in understanding the analysis process, please let me know,  
and if yes, please let me know how can i achieve this goal.

All help will be appreciated. Thanks in advance.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/44e06283-a86c-4d40-b5c4-2b7122d98493%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/44e06283-a86c-4d40-b5c4-2b7122d98493%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 16, 2015, 8:44am UTC](https://discuss.elastic.co/t/customized-analyzers-behave/22146/2 "2015-02-16T08:44:36Z")

</div>

Are you using the same analyser for indexing and querying?

On 13 February 2015 at 16:16, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) wrote:

> Hi All,
> 
> I am trying to write down a custom analyzer like as follows :
> 
> "analysis": {
> 
> ```
> "tokenizer": {
> 
> "my_edge_ngram_tokenizer": {
> 
> "type": "edgeNGram",
> 
> "min_gram": "1",
> 
> "max_gram": "20",
> 
> "token_chars": []
> 
> }
> 
> },
> 
> "filter": {
> 
> "ys_word_delimiter": {
> 
> "type": "word_delimiter",
> 
> "stem_english_possessive": "False"
> 
> }
> 
> },
> 
> "analyzer": {
> 
> "ys_search_analyzer": {
> 
> "type": "custom",
> 
> "tokenizer": "my_edge_ngram_tokenizer",
> 
> "filter": [
> 
> "ys_word_delimiter",
> 
> "lowercase"
> 
> ]
> 
> }
> 
> }
> 
> }
> 
> ```
> 
> Now I need to have a behave for analyzer that if i search for title as\*  
> "ca,usa" OR "ca, usa"\*, both should be searchable using this analyzer.  
> But right now its searching only what has been saved, So if the title is  
> saved with space then space is searchable and if title is saved without  
> space, its searchable without space.
> 
> So I tried to add "trim" filter in the filter list. Expecting, after  
> tokenizer, the token filter will run on the token generated, so " usa" will  
> be convered to "usa" token. so whether the title is without space or with  
> space, the read and write time will finally be changed into a trimmed token  
> after bypassing this analyzer.
> 
> If I am mistaken in understanding the analysis process, please let me  
> know, and if yes, please let me know how can i achieve this goal.
> 
> All help will be appreciated. Thanks in advance.
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/44e06283-a86c-4d40-b5c4-2b7122d98493%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/44e06283-a86c-4d40-b5c4-2b7122d98493%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/44e06283-a86c-4d40-b5c4-2b7122d98493%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/44e06283-a86c-4d40-b5c4-2b7122d98493%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X-MQtRVs\_9fDVciGcjd%3DGHd0D-L0q79pgfbwJZiLFhBVw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X-MQtRVs_9fDVciGcjd%3DGHd0D-L0q79pgfbwJZiLFhBVw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:32am UTC](https://discuss.elastic.co/t/customized-analyzers-behave/22146/3 "2017-07-06T00:32:32Z")

</div>


