# Wildcard analyze does not work for "the"

**URL:** <https://discuss.elastic.co/t/wildcard-analyze-does-not-work-for-the/5190>\
**Category:** Elasticsearch\
**Created:** [August 18, 2011, 9:38am UTC](https://discuss.elastic.co/t/wildcard-analyze-does-not-work-for-the/5190 "2011-08-18T09:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maciej\_Wiercinski](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Maciej\_Wiercinski](https://discuss.elastic.co/u/Maciej_Wiercinski)\
**Post date:** [August 18, 2011, 9:38am UTC](https://discuss.elastic.co/t/wildcard-analyze-does-not-work-for-the/5190/1 "2011-08-18T09:38:16Z")

</div>

Hi,

I'm struggling to get a wildcard query running searching for a string "The  
Times". As far as I understand the tokenizer should remove "The" as a stop  
word while indexing the field, however it does not seem to get applied to  
the wildcard, regardless of "analyze\_wildcard" setting. I've tried changing  
the mapping on "name" field to not\_analyzed, however it didn't help.

Should I report it as a bug, or am I missing something?

Full example:

$ curl -XDELETE 127.0.0.1:9200/test\_index?pretty  
{  
"ok" : true,  
"acknowledged" : true  
}

$ curl -XPUT 127.0.0.1:9200/test\_index/test\_type/1?pretty -d '{ "name": "The  
Times" }';  
{  
"ok" : true,  
"\_index" : "test\_index",  
"\_type" : "test\_type",  
"\_id" : "1",  
"\_version" : 1  
}

$ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
'{"query":{"query\_string":{"query":"the times\*","default\_operator":"AND",  
"analyze\_wildcard": "true" }}}'  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "test\_index",  
"\_type" : "test\_type",  
"\_id" : "1",  
"\_score" : 1.0, "\_source" : {  
"name": "The Times"  
}  
} ]  
}  
}

$ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
'{"query":{"query\_string":{"query":"the\* times\*","default\_operator":"AND",  
"analyze\_wildcard": "true" }}}'  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

$ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
'{"query":{"query\_string":{"query":"the times\*","default\_operator":"AND",  
"analyze\_wildcard": "false" }}}'  
{  
"took" : 0,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "test\_index",  
"\_type" : "test\_type",  
"\_id" : "1",  
"\_score" : 1.0, "\_source" : {  
"name": "The Times"  
}  
} ]  
}  
}

$ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
'{"query":{"query\_string":{"query":"the\* times\*","default\_operator":"AND",  
"analyze\_wildcard": "false" }}}'  
{  
"took" : 0,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

Kind regards,  
Maciej Wiercinski

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [August 19, 2011, 8:56am UTC](https://discuss.elastic.co/t/wildcard-analyze-does-not-work-for-the/5190/2 "2011-08-19T08:56:37Z")

</div>

Hi Maciej

'the' is a stopword, and so is being removed. You can disable stopwords  
with a custom analyzer

clint

> I'm struggling to get a wildcard query running searching for a string  
> "The Times". As far as I understand the tokenizer should remove "The"  
> as a stop word while indexing the field, however it does not seem to  
> get applied to the wildcard, regardless of "analyze\_wildcard" setting.  
> I've tried changing the mapping on "name" field to not\_analyzed,  
> however it didn't help.
> 
> Should I report it as a bug, or am I missing something?
> 
> Full example:
> 
> $ curl -XDELETE 127.0.0.1:9200/test\_index?pretty  
> {  
> "ok" : true,  
> "acknowledged" : true  
> }
> 
> $ curl -XPUT 127.0.0.1:9200/test\_index/test\_type/1?pretty -d  
> '{ "name": "The Times" }';  
> {  
> "ok" : true,  
> "\_index" : "test\_index",  
> "\_type" : "test\_type",  
> "\_id" : "1",  
> "\_version" : 1  
> }
> 
> $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> '{"query":{"query\_string":{"query":"the  
> times\*","default\_operator":"AND", "analyze\_wildcard": "true" }}}'  
> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "test\_index",  
> "\_type" : "test\_type",  
> "\_id" : "1",  
> "\_score" : 1.0, "\_source" : {  
> "name": "The Times"  
> }  
> } ]  
> }  
> }
> 
> $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> '{"query":{"query\_string":{"query":"the\*  
> times\*","default\_operator":"AND", "analyze\_wildcard": "true" }}}'  
> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> '{"query":{"query\_string":{"query":"the  
> times\*","default\_operator":"AND", "analyze\_wildcard": "false" }}}'  
> {  
> "took" : 0,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "test\_index",  
> "\_type" : "test\_type",  
> "\_id" : "1",  
> "\_score" : 1.0, "\_source" : {  
> "name": "The Times"  
> }  
> } ]  
> }  
> }
> 
> $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> '{"query":{"query\_string":{"query":"the\*  
> times\*","default\_operator":"AND", "analyze\_wildcard": "false" }}}'  
> {  
> "took" : 0,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> Kind regards,  
> Maciej Wiercinski

---

<div class="post-metadata">

**Author:** ![Maciej\_Wiercinski](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Maciej\_Wiercinski](https://discuss.elastic.co/u/Maciej_Wiercinski)\
**Post date:** [August 19, 2011, 10:31am UTC](https://discuss.elastic.co/t/wildcard-analyze-does-not-work-for-the/5190/3 "2011-08-19T10:31:08Z")

</div>

Hi Clinton

I do understand that "the" is a stopword, however I still reckon it's  
a bug. If "the" is being removed from the search query in form "the  
AND times\*" and the search yields positive results, then "the\* AND  
times\*" should also be the case - wildcard\_analyze should remove the\*  
part and make the search equivalent to "times\*".

Any thoughts?

Kinds regards,  
Maciej

On Aug 19, 9:56 am, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:

> Hi Maciej
> 
> 'the' is a stopword, and so is being removed. You can disable stopwords  
> with a custom analyzer
> 
> clint
> 
> > I'm struggling to get a wildcard query running searching for a string  
> > "The Times". As far as I understand the tokenizer should remove "The"  
> > as a stop word while indexing the field, however it does not seem to  
> > get applied to the wildcard, regardless of "analyze\_wildcard" setting.  
> > I've tried changing the mapping on "name" field to not\_analyzed,  
> > however it didn't help.
> 
> > Should I report it as a bug, or am I missing something?
> 
> > Full example:
> 
> > $ curl -XDELETE 127.0.0.1:9200/test\_index?pretty  
> > {  
> > "ok" : true,  
> > "acknowledged" : true  
> > }
> 
> > $ curl -XPUT 127.0.0.1:9200/test\_index/test\_type/1?pretty -d  
> > '{ "name": "The Times" }';  
> > {  
> > "ok" : true,  
> > "\_index" : "test\_index",  
> > "\_type" : "test\_type",  
> > "\_id" : "1",  
> > "\_version" : 1  
> > }
> 
> > $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> > '{"query":{"query\_string":{"query":"the  
> > times\*","default\_operator":"AND", "analyze\_wildcard": "true" }}}'  
> > {  
> > "took" : 1,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 1,  
> > "max\_score" : 1.0,  
> > "hits" : [ {  
> > "\_index" : "test\_index",  
> > "\_type" : "test\_type",  
> > "\_id" : "1",  
> > "\_score" : 1.0, "\_source" : {  
> > "name": "The Times"  
> > }  
> > } ]  
> > }  
> > }
> 
> > $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> > '{"query":{"query\_string":{"query":"the\*  
> > times\*","default\_operator":"AND", "analyze\_wildcard": "true" }}}'  
> > {  
> > "took" : 1,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 0,  
> > "max\_score" : null,  
> > "hits" :   
> > }  
> > }
> 
> > $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> > '{"query":{"query\_string":{"query":"the  
> > times\*","default\_operator":"AND", "analyze\_wildcard": "false" }}}'  
> > {  
> > "took" : 0,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 1,  
> > "max\_score" : 1.0,  
> > "hits" : [ {  
> > "\_index" : "test\_index",  
> > "\_type" : "test\_type",  
> > "\_id" : "1",  
> > "\_score" : 1.0, "\_source" : {  
> > "name": "The Times"  
> > }  
> > } ]  
> > }  
> > }
> 
> > $ curl -XGET 127.0.0.1:9200/test\_index/test\_type/\_search?pretty -d  
> > '{"query":{"query\_string":{"query":"the\*  
> > times\*","default\_operator":"AND", "analyze\_wildcard": "false" }}}'  
> > {  
> > "took" : 0,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 0,  
> > "max\_score" : null,  
> > "hits" :   
> > }  
> > }
> 
> > Kind regards,  
> > Maciej Wiercinski

---

<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, 3:56am UTC](https://discuss.elastic.co/t/wildcard-analyze-does-not-work-for-the/5190/4 "2017-07-06T03:56:33Z")

</div>


