# Wildcard can not search non-English text

**URL:** <https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917>\
**Category:** Elasticsearch\
**Created:** [December 9, 2017, 3:56am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917 "2017-12-09T03:56:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruce88](https://avatars.discourse-cdn.com/v4/letter/b/b3f665/32.png) [@bruce88](https://discuss.elastic.co/u/bruce88)\
**Post date:** [December 9, 2017, 3:56am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917/1 "2017-12-09T03:56:05Z")

</div>

Yesterday, I used wildcard to search some keywords, but it alway failed to hit the non-English text. Informations are as below.

- Query Clause  
{  
"query": {  
"bool": {  
"should": [  
{  
"wildcard": {  
"temp\_path": "`*`kimch`*`"  
}  
},  
{  
"wildcard": {  
"temp\_path": "`*`迷惑メール`*`"  
}  
}  
]  
}  
}  
}

- The field temp\_path is "text" type and "not\_analyzed".

According to the document, "In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards `*` or `?`. ", I used "迷惑メール`*`", instead of "`*`迷惑メール`*`", then it succeeded to hit the Japanese text.

So my question is: for the wildcard term like "`*`xxx`*`", why it can work on English text, but can not hit non-English text?

Thanks!

- Bruce, 2017/12/09

---

<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:** [December 9, 2017, 4:37am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917/2 "2017-12-09T04:37:47Z")

</div>

1st: avoid wildcards!

2nd: it’s probably happening because your text has been analyzed with the default analyzer at index time but when using wildcards the text is not analyzed. So analyzed terms and non analyzed terms don’t match.

Try to see what the `_analyze` API is telling you about the way your text is analyzed and you’ll get a better idea.

---

<div class="post-metadata">

**Author:** ![bruce88](https://avatars.discourse-cdn.com/v4/letter/b/b3f665/32.png) [@bruce88](https://discuss.elastic.co/u/bruce88)\
**Post date:** [December 9, 2017, 7:14am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917/3 "2017-12-09T07:14:39Z")

</div>

Hi David

Thank you for reply.  
I totally agree with you that we should avoid wildcards. I'm sure the field is not analyzed.  
{

"settings": {

"number\_of\_shards": 1

},

"mappings": {

"test": {

"properties": {

"temp\_path": {

"type": "text",

"index": "not\_analyzed"

}

}

}

}

}

I'm just curious why "`*`迷惑メール`*`" can not hit the text, but "迷惑メール`*`" can. And why "`*`kimch`*`" can hit all English text.

Bruce

---

<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:** [December 9, 2017, 8:52am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917/4 "2017-12-09T08:52:18Z")

</div>

So your text is not analyzed. Interesting.

@johtani do you have an idea?

---

<div class="post-metadata">

**Author:** ![bruce88](https://avatars.discourse-cdn.com/v4/letter/b/b3f665/32.png) [@bruce88](https://discuss.elastic.co/u/bruce88)\
**Post date:** [December 9, 2017, 11:46am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917/5 "2017-12-09T11:46:32Z")

</div>

Hi David

It's my fault to misuse "type:text" and "type:string". You are right, the text is analyzed. Sorry for your time.  
And anyone else who viewing this topic, please be careful about this.

~~  
The string field datatype has been replaced by the text field for full text analyzed content, and the keyword field for not-analyzed exact string values.  
~~

Bruce

---

<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:** [January 6, 2018, 11:46am UTC](https://discuss.elastic.co/t/wildcard-can-not-search-non-english-text/110917/6 "2018-01-06T11:46:51Z")

</div>

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