# Query String Query for case insensitive matching using ES-Spark connector

**URL:** <https://discuss.elastic.co/t/query-string-query-for-case-insensitive-matching-using-es-spark-connector/120242>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [February 16, 2018, 8:08pm UTC](https://discuss.elastic.co/t/query-string-query-for-case-insensitive-matching-using-es-spark-connector/120242 "2018-02-16T20:08:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pramod\_Sripada](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@Pramod\_Sripada](https://discuss.elastic.co/u/Pramod_Sripada)\
**Post date:** [February 16, 2018, 8:08pm UTC](https://discuss.elastic.co/t/query-string-query-for-case-insensitive-matching-using-es-spark-connector/120242/1 "2018-02-16T20:08:48Z")

</div>

Hi, I am using ES-Spark connector and trying to push filters down to ES, so that Spark would have exact data for processing .

I am trying to perform a case insensitive value match on a column value but unable to perform it using a normal filter (pushed down as a wildcard) because it is strictly matching the case. I have read on Stackoverflow that to perform case insensitive matching we need to use a query string. How can we specify a query string query in Spark DataFrame operations.

Current code for filter

`df = spark.read.format("es").load("es_index").filter("business_name LIKE '%Walmart%')`

which would push the filters down to the ES like

```
               {
               "wildcard":{
                  "business_name":"*Walmart*"
               }

```

The wildcard is case sensitive and will not match for ex: `walmart`. Could you please let me know how this can be achieved with the ES-Spark connector.

Thanks

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [March 1, 2018, 9:43pm UTC](https://discuss.elastic.co/t/query-string-query-for-case-insensitive-matching-using-es-spark-connector/120242/2 "2018-03-01T21:43:19Z")

</div>

One way you could do this is use a custom analyzer for the fields you are searching for: [How to do case insensitive search on terms?](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/2)

---

<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 29, 2018, 9:43pm UTC](https://discuss.elastic.co/t/query-string-query-for-case-insensitive-matching-using-es-spark-connector/120242/3 "2018-03-29T21:43:26Z")

</div>

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