# Filtering for two chars strings on keyword field does not work?

**URL:** <https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409>\
**Category:** Elasticsearch\
**Created:** [January 21, 2018, 10:36pm UTC](https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409 "2018-01-21T22:36:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ste2c](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@ste2c](https://discuss.elastic.co/u/ste2c)\
**Post date:** [January 21, 2018, 10:36pm UTC](https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409/1 "2018-01-21T22:36:11Z")

</div>

Hi all,  
I cannot understand how to filter for two chars strings a simple keyword field. I created the field like this:

```
"tags": {
  "store": True,
  "type": "keyword"
},

```

..the "tags" field is then populated with a list (i.e. [''ai", "iot"] and filtered using:

```
"query": {
  "terms":{
    "tags": tags
  }

```

..which works fine for filtering documents tags by "iot", but does not return any result when filtering by "AI".

..what am I missing? I Googled and dived in the official doc for hours but I cannot figure it out. The only references that I found about a minimum length are referred to ngrams, which I am not using (right?).

Thank you!  
Stefano.

---

<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 22, 2018, 4:29am UTC](https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409/2 "2018-01-22T04:29:00Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

---

<div class="post-metadata">

**Author:** ![ste2c](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@ste2c](https://discuss.elastic.co/u/ste2c)\
**Post date:** [January 22, 2018, 12:15pm UTC](https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409/3 "2018-01-22T12:15:17Z")

</div>

Nevermind, it was a case-sensitiveness problem together with poor test coverage on my code.

Sorry for not having posted a full recreation script, I would have spotted the problem and avoided a useless topic. My bad.

So the answer is no, it is not true that filtering for two chars strings on keyword field does not work. But check for case as it is a case sensitive field.

Cheers,  
Stefano.

---

<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 22, 2018, 12:44pm UTC](https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409/4 "2018-01-22T12:44:07Z")

</div>

> Sorry for not having posted a full recreation script, I would have spotted the problem and avoided a useless topic. My bad.

😉

No worries. That's why we are often asking for simple recreation script as most of the time users are finding themselves what the problem is and how to solve.

---

<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:** [February 19, 2018, 12:44pm UTC](https://discuss.elastic.co/t/filtering-for-two-chars-strings-on-keyword-field-does-not-work/116409/5 "2018-02-19T12:44:32Z")

</div>

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