# Elasticsearch can't hanlde space after add analyzer

**URL:** <https://discuss.elastic.co/t/elasticsearch-cant-hanlde-space-after-add-analyzer/300509>\
**Category:** Elasticsearch\
**Created:** [March 24, 2022, 1:05am UTC](https://discuss.elastic.co/t/elasticsearch-cant-hanlde-space-after-add-analyzer/300509 "2022-03-24T01:05:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muhammad\_Fhadli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammad_fhadli/32/102950_2.png) [@Muhammad\_Fhadli](https://discuss.elastic.co/u/Muhammad_Fhadli)\
**Post date:** [March 24, 2022, 1:05am UTC](https://discuss.elastic.co/t/elasticsearch-cant-hanlde-space-after-add-analyzer/300509/1 "2022-03-24T01:05:53Z")

</div>

I created an index called `my_index` by this command

```auto
{
    "settings": {
        "number_of_shards": 1,
        "analysis": {
            "filter": {
                "synonym": {
                    "type": "synonym",
                    "lenient": "true",
                    "synonyms": [
                        ...
                        ...
                        ...
                    ]
                }
            },
            "analyzer": {
                "synonym": {
                    "filter": [
                        "uppercase",
                        "synonym"
                    ],
                    "tokenizer": "whitespace"
                }
            }
        }
    },
    "mappings": {
        "items": {
            "properties": {
                "country": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "information": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    },
                    "analyzer": "synonym"
                },
                "person": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                }
            }
        }
    }
}

```

inside `information`, I had a data that looks like this `100 /INDIA/2022` (pay attention to the space after 100). If i search for `100/INDIA/2022` (no space after 100), Elasticsearch will return nothing. If I create new index with no analyzer, `100/INDIA/2022` will return the expected result. Can someone help me for this problem?

---

<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:** [March 24, 2022, 6:13am UTC](https://discuss.elastic.co/t/elasticsearch-cant-hanlde-space-after-add-analyzer/300509/2 "2022-03-24T06:13:17Z")

</div>

That's indeed because of the analyzer used.  
In the first example, your analyzer is using a whitespace tokenizer at index time and search time.

The second example uses a standard tokenizer.

Use the \_analyze API to understand how your text is transformed at index time **and** at search time.

If you can't find the same tokens, that explains why the search does not give any result.

---

<div class="post-metadata">

**Author:** ![Muhammad\_Fhadli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammad_fhadli/32/102950_2.png) [@Muhammad\_Fhadli](https://discuss.elastic.co/u/Muhammad_Fhadli)\
**Post date:** [March 24, 2022, 9:35am UTC](https://discuss.elastic.co/t/elasticsearch-cant-hanlde-space-after-add-analyzer/300509/4 "2022-03-24T09:35:48Z")

</div>

I see. It seems that change the `tokenizer` into `standard` solved the problem. Thank you

---

<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:** [April 21, 2022, 9:35am UTC](https://discuss.elastic.co/t/elasticsearch-cant-hanlde-space-after-add-analyzer/300509/5 "2022-04-21T09:35:54Z")

</div>

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