# Case sensitivity

**URL:** <https://discuss.elastic.co/t/case-sensitivity/5249>\
**Category:** Elasticsearch\
**Created:** [August 25, 2011, 2:46pm UTC](https://discuss.elastic.co/t/case-sensitivity/5249 "2011-08-25T14:46:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Burkey\_3](https://avatars.discourse-cdn.com/v4/letter/c/edb3f5/32.png) [@Christopher\_Burkey\_3](https://discuss.elastic.co/u/Christopher_Burkey_3)\
**Post date:** [August 25, 2011, 2:46pm UTC](https://discuss.elastic.co/t/case-sensitivity/5249/1 "2011-08-25T14:46:27Z")

</div>

Do I need to lower case my searches before I send them to Elasticsearch? I  
would think for text and wildcard queries Elasticsearch search\_analyzer  
would take care of it.

Here is a test that searches for "TR" in uppercase and does not get results.  
Lowercasing the query by hand seems to work but the search\_analyzer should  
have been applied in a consistent way.

set -o verbose #echo on  
#set +o verbose #echo off

SERVER="[http://localhost:9200/twitter](http://localhost:9200/twitter)"

curl -XDELETE $SERVER | python -mjson.tool

curl -XPOST $SERVER -d '  
{"index":  
{ "number\_of\_shards": 1,  
"analysis": {  
"filter": {  
"snowball": {  
"type" : "snowball",  
"language" : "English"  
}  
},  
"analyzer": { "a2" : {  
"type":"custom",  
"tokenizer": "standard",  
"filter": ["lowercase", "snowball"]  
}  
}  
}  
}  
}  
}' | python -mjson.tool

sleep 1

curl -XPUT $SERVER/tweet/\_mapping -d '{  
"tweet" : {  
"properties" : {  
"message" : {"type" : "string",  
"analyzer":"a2","include\_in\_all":"true"},  
"user": {"type":"string"}  
}  
}}' | python -mjson.tool

sleep 1

curl -XPUT $SERVER/tweet/1 -d '{ "user": "kimchy", "message": "Trying out  
searching teaching, so far so good?" }' | python -mjson.tool

sleep 1

curl -XGET $SERVER/tweet/\_search?q=message:teach | python -mjson.tool

sleep 1

curl -XPOST $SERVER/tweet/\_search -d '{  
"query":  
{  
"wildcard" : {  
"message" : "TR\*"  
}  
}  
}' | python -mjson.tool

echo "Should have a hit"

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 25, 2011, 10:47pm UTC](https://discuss.elastic.co/t/case-sensitivity/5249/2 "2011-08-25T22:47:03Z")

</div>

According to the docs, a wildcard query is not analyzed:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Since your terms are analyzed with a standard analyzer (lower cased),  
your query must also be lower-cased.

--  
Ivan

On Thu, Aug 25, 2011 at 10:46 AM, Christopher Burkey  
[cburkey@openedit.org](mailto:cburkey@openedit.org) wrote:

> Do I need to lower case my searches before I send them to Elasticsearch? I  
> would think for text and wildcard queries Elasticsearch search\_analyzer  
> would take care of it.
> 
> Here is a test that searches for "TR" in uppercase and does not get results.  
> Lowercasing the query by hand seems to work but the search\_analyzer should  
> have been applied in a consistent way.
> 
> set -o verbose #echo on  
> #set +o verbose #echo off
> 
> SERVER="[http://localhost:9200/twitter](http://localhost:9200/twitter)"
> 
> curl -XDELETE $SERVER | python -mjson.tool
> 
> curl -XPOST $SERVER -d '  
> {"index":  
> { "number\_of\_shards": 1,  
> "analysis": {  
> "filter": {  
> "snowball": {  
> "type" : "snowball",  
> "language" : "English"  
> }  
> },  
> "analyzer": { "a2" : {  
> "type":"custom",  
> "tokenizer": "standard",  
> "filter": ["lowercase", "snowball"]  
> }  
> }  
> }  
> }  
> }  
> }' | python -mjson.tool
> 
> sleep 1
> 
> curl -XPUT $SERVER/tweet/\_mapping -d '{  
> "tweet" : {  
> "properties" : {  
> "message" : {"type" : "string",  
> "analyzer":"a2","include\_in\_all":"true"},  
> "user": {"type":"string"}  
> }  
> }}' | python -mjson.tool
> 
> sleep 1
> 
> curl -XPUT $SERVER/tweet/1 -d '{ "user": "kimchy", "message": "Trying out  
> searching teaching, so far so good?" }' | python -mjson.tool
> 
> sleep 1
> 
> curl -XGET $SERVER/tweet/\_search?q=message:teach | python -mjson.tool
> 
> sleep 1
> 
> curl -XPOST $SERVER/tweet/\_search -d '{  
> "query":  
> {  
> "wildcard" : {  
> "message" : "TR\*"  
> }  
> }  
> }' | python -mjson.tool
> 
> echo "Should have a hit"

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 26, 2011, 2:08pm UTC](https://discuss.elastic.co/t/case-sensitivity/5249/3 "2011-08-26T14:08:57Z")

</div>

Check the text family of queries, they might do what you are after:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html).

On Fri, Aug 26, 2011 at 1:47 AM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> According to the docs, a wildcard query is not analyzed:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/wildcard-query.html)
> 
> Since your terms are analyzed with a standard analyzer (lower cased),  
> your query must also be lower-cased.
> 
> --  
> Ivan
> 
> On Thu, Aug 25, 2011 at 10:46 AM, Christopher Burkey  
> [cburkey@openedit.org](mailto:cburkey@openedit.org) wrote:
> 
> > Do I need to lower case my searches before I send them to Elasticsearch?  
> > I  
> > would think for text and wildcard queries Elasticsearch search\_analyzer  
> > would take care of it.
> > 
> > Here is a test that searches for "TR" in uppercase and does not get  
> > results.  
> > Lowercasing the query by hand seems to work but the search\_analyzer  
> > should  
> > have been applied in a consistent way.
> > 
> > set -o verbose #echo on  
> > #set +o verbose #echo off
> > 
> > SERVER="[http://localhost:9200/twitter](http://localhost:9200/twitter)"
> > 
> > curl -XDELETE $SERVER | python -mjson.tool
> > 
> > curl -XPOST $SERVER -d '  
> > {"index":  
> > { "number\_of\_shards": 1,  
> > "analysis": {  
> > "filter": {  
> > "snowball": {  
> > "type" : "snowball",  
> > "language" : "English"  
> > }  
> > },  
> > "analyzer": { "a2" : {  
> > "type":"custom",  
> > "tokenizer": "standard",  
> > "filter": ["lowercase", "snowball"]  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }' | python -mjson.tool
> > 
> > sleep 1
> > 
> > curl -XPUT $SERVER/tweet/\_mapping -d '{  
> > "tweet" : {  
> > "properties" : {  
> > "message" : {"type" : "string",  
> > "analyzer":"a2","include\_in\_all":"true"},  
> > "user": {"type":"string"}  
> > }  
> > }}' | python -mjson.tool
> > 
> > sleep 1
> > 
> > curl -XPUT $SERVER/tweet/1 -d '{ "user": "kimchy", "message": "Trying out  
> > searching teaching, so far so good?" }' | python -mjson.tool
> > 
> > sleep 1
> > 
> > curl -XGET $SERVER/tweet/\_search?q=message:teach | python -mjson.tool
> > 
> > sleep 1
> > 
> > curl -XPOST $SERVER/tweet/\_search -d '{  
> > "query":  
> > {  
> > "wildcard" : {  
> > "message" : "TR\*"  
> > }  
> > }  
> > }' | python -mjson.tool
> > 
> > echo "Should have a hit"

---

<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:55am UTC](https://discuss.elastic.co/t/case-sensitivity/5249/4 "2017-07-06T03:55:58Z")

</div>


