# Case sensitive/insensitive search combination in phrase/proximity query

**URL:** <https://discuss.elastic.co/t/case-sensitive-insensitive-search-combination-in-phrase-proximity-query/20667>\
**Category:** Elasticsearch\
**Created:** [November 10, 2014, 5:22pm UTC](https://discuss.elastic.co/t/case-sensitive-insensitive-search-combination-in-phrase-proximity-query/20667 "2014-11-10T17:22:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zdeseb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zdeseb/32/42106_2.png) [@zdeseb](https://discuss.elastic.co/u/zdeseb)\
**Post date:** [November 10, 2014, 5:22pm UTC](https://discuss.elastic.co/t/case-sensitive-insensitive-search-combination-in-phrase-proximity-query/20667/1 "2014-11-10T17:22:18Z")

</div>

Hi,  
is there any way how to search part of phrase as case-sensitive and part as  
case-insensitive?

The only solution I found for case sensitive/insensitive querying is to  
have multiple analyzers applied to one field (one analyzer with lowercase  
token filter and one without)

With this solution I can search in following way

Field.lowercase: "My Phrase"

or

Field.sensitive: "My Phrase"

_But what to do if I whould like to search "My" as case sensitive and  
"Phrase" as case insensitive?_

I found _span\_near_ query but error message sais that "_Clauses must have  
same field_"

Thanks,  
Zdenek

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/de3a6085-5ecb-4486-a3aa-1a7162aaeed4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/de3a6085-5ecb-4486-a3aa-1a7162aaeed4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 10, 2014, 5:26pm UTC](https://discuss.elastic.co/t/case-sensitive-insensitive-search-combination-in-phrase-proximity-query/20667/2 "2014-11-10T17:26:51Z")

</div>

I don't believe there is a way to do that now.

On Mon, Nov 10, 2014 at 12:22 PM, Zdeněk [zdenek.sebl@gmail.com](mailto:zdenek.sebl@gmail.com) wrote:

> Hi,  
> is there any way how to search part of phrase as case-sensitive and part  
> as case-insensitive?
> 
> The only solution I found for case sensitive/insensitive querying is to  
> have multiple analyzers applied to one field (one analyzer with lowercase  
> token filter and one without)
> 
> With this solution I can search in following way
> 
> Field.lowercase: "My Phrase"
> 
> or
> 
> Field.sensitive: "My Phrase"
> 
> _But what to do if I whould like to search "My" as case sensitive and  
> "Phrase" as case insensitive?_
> 
> I found _span\_near_ query but error message sais that "_Clauses must have  
> same field_"
> 
> Thanks,  
> Zdenek
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/de3a6085-5ecb-4486-a3aa-1a7162aaeed4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/de3a6085-5ecb-4486-a3aa-1a7162aaeed4%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/de3a6085-5ecb-4486-a3aa-1a7162aaeed4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/de3a6085-5ecb-4486-a3aa-1a7162aaeed4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd1eHnEPq1oV%2BCBPS0i-aKXyJVmLLawtqDz2V%3DO13t6LKA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd1eHnEPq1oV%2BCBPS0i-aKXyJVmLLawtqDz2V%3DO13t6LKA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![asthanaamish](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@asthanaamish](https://discuss.elastic.co/u/asthanaamish)\
**Post date:** [November 11, 2014, 6:54pm UTC](https://discuss.elastic.co/t/case-sensitive-insensitive-search-combination-in-phrase-proximity-query/20667/3 "2014-11-11T18:54:18Z")

</div>

Maybe the question to ask will be how do you determine which part of phrase  
will be searched as case sensitive and which will be not.  
If that logic is consistent it can be applied at indexing itself, and same  
analyzer used for search.  
regards and thanks  
amish

On Monday, November 10, 2014 9:22:19 AM UTC-8, Zdeněk Šebl wrote:

> Hi,  
> is there any way how to search part of phrase as case-sensitive and part  
> as case-insensitive?
> 
> The only solution I found for case sensitive/insensitive querying is to  
> have multiple analyzers applied to one field (one analyzer with lowercase  
> token filter and one without)
> 
> With this solution I can search in following way
> 
> Field.lowercase: "My Phrase"
> 
> or
> 
> Field.sensitive: "My Phrase"
> 
> _But what to do if I whould like to search "My" as case sensitive and  
> "Phrase" as case insensitive?_
> 
> I found _span\_near_ query but error message sais that "_Clauses must have  
> same field_"
> 
> Thanks,  
> Zdenek

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a7bc12f9-2056-4b0b-b0dc-b2c8403e3741%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a7bc12f9-2056-4b0b-b0dc-b2c8403e3741%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:50am UTC](https://discuss.elastic.co/t/case-sensitive-insensitive-search-combination-in-phrase-proximity-query/20667/4 "2017-07-06T00:50:44Z")

</div>


