# How to specify which analyzed elasticsearch field is to be used via SQl query

**URL:** <https://discuss.elastic.co/t/how-to-specify-which-analyzed-elasticsearch-field-is-to-be-used-via-sql-query/40685>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [February 2, 2016, 12:18am UTC](https://discuss.elastic.co/t/how-to-specify-which-analyzed-elasticsearch-field-is-to-be-used-via-sql-query/40685 "2016-02-02T00:18:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robbie](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Robbie](https://discuss.elastic.co/u/Robbie)\
**Post date:** [February 2, 2016, 12:18am UTC](https://discuss.elastic.co/t/how-to-specify-which-analyzed-elasticsearch-field-is-to-be-used-via-sql-query/40685/1 "2016-02-02T00:18:49Z")

</div>

Hi,  
My ES mapping has each field analyzed in a few different ways. Can I control which of the analyzed field will be used when I make a spark-sql query via the ES connector? Currently, it looks like it uses the non-analyzed version if "strict" is true, or the analyzed version otherwise.

For instance, below is one of the fields that I have in my ES index  
`"name": { "type": "string", "analyzer": "custom_pattern_index", "fields": { "nonanalyzed": { "type": "string", "analyzer": "custom_non_analyzer" }, "whitespace": { "type": "string", "analyzer": "custom_whitespace_analyzer" } } }`

In such a case, how do I ensure that my SQL query/ DataFrame.filter gets fired against name.whitespace instead of name?

Thanks!

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [February 21, 2016, 5:56pm UTC](https://discuss.elastic.co/t/how-to-specify-which-analyzed-elasticsearch-field-is-to-be-used-via-sql-query/40685/2 "2016-02-21T17:56:46Z")

</div>

There isn't any option yet in ES-Spark to change the field name to a different one. It shouldn't be hard to do however the question remains whether to do it globally (to apply the new field for filters used in a Spark context) or per Data Frame?  
Also outside not analysed fields, I'm wondering whether is there anything else to have one configuration to include all the options.

---

<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, 1:26pm UTC](https://discuss.elastic.co/t/how-to-specify-which-analyzed-elasticsearch-field-is-to-be-used-via-sql-query/40685/3 "2017-07-06T13:26:11Z")

</div>


