# Query with wildcard do not return result if the item has data repeat more than 2 times

**URL:** <https://discuss.elastic.co/t/query-with-wildcard-do-not-return-result-if-the-item-has-data-repeat-more-than-2-times/289500>\
**Category:** Elasticsearch\
**Created:** [November 17, 2021, 7:04pm UTC](https://discuss.elastic.co/t/query-with-wildcard-do-not-return-result-if-the-item-has-data-repeat-more-than-2-times/289500 "2021-11-17T19:04:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tu\_Phan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tu_phan/32/97239_2.png) [@Tu\_Phan](https://discuss.elastic.co/u/Tu_Phan)\
**Post date:** [November 17, 2021, 7:04pm UTC](https://discuss.elastic.co/t/query-with-wildcard-do-not-return-result-if-the-item-has-data-repeat-more-than-2-times/289500/1 "2021-11-17T19:04:54Z")

</div>

Hi Elastic team & community,  
I got a trouble with wildcard query do not return expected result when having items with repeated data.  
With the code below I expected that search query returns 2 items but it returns only 1.

Please help me to update the query to get the right result ?

```auto

## CREATE SHORT DATA
POST /test/_doc
{
  "content": "ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜"
}

# CREATE LONG DATA
POST /test/_doc
{
  "content": "ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ0123456789～！＠＃＄％＾＆＊（）＿＋－＝］￥｝｜”；：／＞＜"
}

# QUERY
POST /test/_search 
{ "size": 10000,
  "query": {
    "bool": {
      "should": [
        {"wildcard": { "content.keyword": {
          "value": "*ＰＱＲＳＴＵＶＷＸＹＺ*"
        }}}
      ]
    } 
  }
}

```

Thank you very much!!!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 17, 2021, 7:31pm UTC](https://discuss.elastic.co/t/query-with-wildcard-do-not-return-result-if-the-item-has-data-repeat-more-than-2-times/289500/2 "2021-11-17T19:31:26Z")

</div>

If you are using the default mappings the keyword field comes with a [default ignore\_above set to 256](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/keyword.html#keyword-params). If your string is longer than that, which I suspect may be the case for your second document, it will not be indexed and therefore not found in the search.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 19, 2021, 11:11am UTC](https://discuss.elastic.co/t/query-with-wildcard-do-not-return-result-if-the-item-has-data-repeat-more-than-2-times/289500/3 "2021-11-19T11:11:46Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> If your string is longer than that, which I suspect may be the case for your second document, it will not be indexed and therefore not found in the search.

Note the new [wildcard field](https://www.elastic.co/blog/find-strings-within-strings-faster-with-the-new-elasticsearch-wildcard-field) has been designed to overcome the size limits of `keyword` and may be of interest (see the decision chart at the end of the blog though).

---

<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:** [December 17, 2021, 11:11am UTC](https://discuss.elastic.co/t/query-with-wildcard-do-not-return-result-if-the-item-has-data-repeat-more-than-2-times/289500/4 "2021-12-17T11:11:59Z")

</div>

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