# How could I do to set es query case sensitive?

**URL:** <https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171>\
**Category:** Elasticsearch\
**Created:** [February 2, 2018, 7:10am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171 "2018-02-02T07:10:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuanyetouci](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xuanyetouci](https://discuss.elastic.co/u/xuanyetouci)\
**Post date:** [February 2, 2018, 7:10am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171/1 "2018-02-02T07:10:33Z")

</div>

```
GET _search
{
  "query": {
    "match": {
      "name": "3g"
    }
  }
}    

```

now I can get named 3g and 3G  
how counld I do to only get named 3g?

---

<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:** [February 2, 2018, 7:28am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171/2 "2018-02-02T07:28:37Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

Please edit your post.

You can change the analyzer or the type of the field. For example, use a `keyword` type instead of `text`.  
If you are using all defaults, then you can probably do:

```auto
GET _search
{
  "query": {
    "match": {
      "name.keyword": "3g"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![xuanyetouci](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xuanyetouci](https://discuss.elastic.co/u/xuanyetouci)\
**Post date:** [February 2, 2018, 7:43am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171/3 "2018-02-02T07:43:24Z")

</div>

Thank you very much for your help.  
I use `name.keyword` seems not work,  
But I use kibana find a hint `.raw` seems work.

---

<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:** [February 2, 2018, 8:02am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171/4 "2018-02-02T08:02:33Z")

</div>

I believe you'd better provide your own mapping instead of relying on default mapping.

The default `foo.raw` subfield was an old one. Default moved to `foo.keyword` in more recent versions.

---

<div class="post-metadata">

**Author:** ![xuanyetouci](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xuanyetouci](https://discuss.elastic.co/u/xuanyetouci)\
**Post date:** [February 2, 2018, 9:25am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171/5 "2018-02-02T09:25:47Z")

</div>

yes, I will try it,  
and I must thank you again for your generous help.

---

<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:** [March 2, 2018, 9:26am UTC](https://discuss.elastic.co/t/how-could-i-do-to-set-es-query-case-sensitive/118171/6 "2018-03-02T09:26:00Z")

</div>

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