# WildcardQuery and case sensitivity

**URL:** <https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806>\
**Category:** Elasticsearch\
**Created:** [November 8, 2011, 6:41am UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806 "2011-11-08T06:41:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish\_Pandit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_pandit/32/3000_2.png) [@Manish\_Pandit](https://discuss.elastic.co/u/Manish_Pandit)\
**Post date:** [November 8, 2011, 6:41am UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806/1 "2011-11-08T06:41:44Z")

</div>

Hi,

I wanted to know if the wildcardQueries are case sensitive - I have an  
un-analyzed field which I am querying using a wildcardQuery, but for  
some reason not getting any results when I change the case of the  
search text. Please let me know if I could be doing this wrong or if  
this is expected behavior.

-cheers,  
Manish

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [November 8, 2011, 7:03am UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806/2 "2011-11-08T07:03:26Z")

</div>

Do you have a lower case token filter for indexing + searching?

Peter.

On Nov 8, 7:41 am, Manish Pandit [pandit.man...@gmail.com](mailto:pandit.man...@gmail.com) wrote:

> Hi,
> 
> I wanted to know if the wildcardQueries are case sensitive - I have an  
> un-analyzed field which I am querying using a wildcardQuery, but for  
> some reason not getting any results when I change the case of the  
> search text. Please let me know if I could be doing this wrong or if  
> this is expected behavior.
> 
> -cheers,  
> Manish

---

<div class="post-metadata">

**Author:** ![Manish\_Pandit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_pandit/32/3000_2.png) [@Manish\_Pandit](https://discuss.elastic.co/u/Manish_Pandit)\
**Post date:** [November 8, 2011, 7:08am UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806/3 "2011-11-08T07:08:30Z")

</div>

On Nov 7, 11:03 pm, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:

> Do you have a lower case token filter for indexing + searching?
> 
> Peter.
> 
> On Nov 8, 7:41 am, Manish Pandit [pandit.man...@gmail.com](mailto:pandit.man...@gmail.com) wrote:
> 
> > Hi,
> 
> > I wanted to know if the wildcardQueries are case sensitive - I have an  
> > un-analyzed field which I am querying using a wildcardQuery, but for  
> > some reason not getting any results when I change the case of the  
> > search text. Please let me know if I could be doing this wrong or if  
> > this is expected behavior.
> 
> > -cheers,  
> > Manish

Nope, everything is default. Not specifying any custom or out of the  
box filter or indexer.

-cheers,  
Manish

---

<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:** [November 9, 2011, 10:35am UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806/4 "2011-11-09T10:35:18Z")

</div>

The wildcard query does not perform any analysis on the text you provide as  
the query. If the field you index on is analyzed, this can be problematic  
(like indexing "Snow", but not finding "Sn\*").

On Tue, Nov 8, 2011 at 9:08 AM, Manish Pandit [pandit.manish@gmail.com](mailto:pandit.manish@gmail.com)wrote:

> On Nov 7, 11:03 pm, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> 
> > Do you have a lower case token filter for indexing + searching?
> > 
> > Peter.
> > 
> > On Nov 8, 7:41 am, Manish Pandit [pandit.man...@gmail.com](mailto:pandit.man...@gmail.com) wrote:
> > 
> > > Hi,
> > 
> > > I wanted to know if the wildcardQueries are case sensitive - I have an  
> > > un-analyzed field which I am querying using a wildcardQuery, but for  
> > > some reason not getting any results when I change the case of the  
> > > search text. Please let me know if I could be doing this wrong or if  
> > > this is expected behavior.
> > 
> > > -cheers,  
> > > Manish
> 
> Nope, everything is default. Not specifying any custom or out of the  
> box filter or indexer.
> 
> -cheers,  
> Manish

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 9, 2011, 3:32pm UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806/5 "2011-11-09T15:32:21Z")

</div>

Manish,

It's possible that I misunderstood your question. But if you have a field  
that is not analyzed (you have specified "index" : "not\_analyzed" in the  
mapping), you might be hitting this lucene feature:  
[http://wiki.apache.org/lucene-java/LuceneFAQ#Are\_Wildcard.2C\_Prefix.2C\_and\_Fuzzy\_queries\_case\_sensitive.3F](http://wiki.apache.org/lucene-java/LuceneFAQ#Are_Wildcard.2C_Prefix.2C_and_Fuzzy_queries_case_sensitive.3F)

Basically, if you index word "Snow" in a field that is not analyzed, it's  
indexed as "Snow". But if you search for "Sn\*", your query is getting  
translated into Lucene prefix query for prefix "sn". In other words Lucene  
lowercases your wildcard queries by default. As a result, you query for  
"Sn\*" doesn't return "Snow", but it may return "snow", for example. You can  
turn this feature off by specifying "lowercase\_expanded\_terms": false in  
your query:

curl -s -XGET "[http://localhost:9200/testindex/\_search](http://localhost:9200/testindex/_search)" -d '{"query":  
{"query\_string": {"query": "testfield:Sn\*", "lowercase\_expanded\_terms":  
false }}}"' ; echo

Igor

On Wed, Nov 9, 2011 at 5:35 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> The wildcard query does not perform any analysis on the text you provide  
> as the query. If the field you index on is analyzed, this can be  
> problematic (like indexing "Snow", but not finding "Sn\*").
> 
> On Tue, Nov 8, 2011 at 9:08 AM, Manish Pandit [pandit.manish@gmail.com](mailto:pandit.manish@gmail.com)wrote:
> 
> > On Nov 7, 11:03 pm, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> > 
> > > Do you have a lower case token filter for indexing + searching?
> > > 
> > > Peter.
> > > 
> > > On Nov 8, 7:41 am, Manish Pandit [pandit.man...@gmail.com](mailto:pandit.man...@gmail.com) wrote:
> > > 
> > > > Hi,
> > > 
> > > > I wanted to know if the wildcardQueries are case sensitive - I have an  
> > > > un-analyzed field which I am querying using a wildcardQuery, but for  
> > > > some reason not getting any results when I change the case of the  
> > > > search text. Please let me know if I could be doing this wrong or if  
> > > > this is expected behavior.
> > > 
> > > > -cheers,  
> > > > Manish
> > 
> > Nope, everything is default. Not specifying any custom or out of the  
> > box filter or indexer.
> > 
> > -cheers,  
> > Manish

---

<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:49am UTC](https://discuss.elastic.co/t/wildcardquery-and-case-sensitivity/5806/6 "2017-07-06T03:49:16Z")

</div>


