# Query\_string filter syntax bug (v1.7)

**URL:** https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215
**Category:** Elasticsearch
**Created:** [January 27, 2016, 10:21am UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215 "2016-01-27T10:21:38Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)
#### Post date: [January 27, 2016, 10:21am UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/1 "2016-01-27T10:21:38Z")

</div>

im looking for the bug in the following query, as it doesn't bring any results. i want it to act like terms filter, and look for exact values in the country / device fields

```
    GET idx/type/_search
    {
     "query": {
     "filtered": {
      "filter": {
        "and": {
          "filters": [
            {
              "query": {
                "query_string": {
                  "query": "country:\"united kingdom\" AND device:\"desktop\""
                }
              }
            }
          ]
        }
      }
    }
    }
    }

```

specifically, this works:

```
 "query": {
                "query_string": {
                  "query": "\"united kingdom\""
                }
              }

```

but this doesnt work:

```
"query": {
                "query_string": {
                  "query": "country:\"united kingdom\""
                }
              }
```

---

<div class="post-metadata">

### Author: ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)
#### Post date: [January 27, 2016, 10:31am UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/2 "2016-01-27T10:31:28Z")

</div>

Hi,

This query is basically a match all that filters on country and device. You can use a simple boolean query with 2 `must` clauses, each clause being a `match` query (or `term` query if your fields are not\_analyzed)

---

<div class="post-metadata">

### Author: ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)
#### Post date: [January 27, 2016, 11:42am UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/3 "2016-01-27T11:42:36Z")

</div>

i want to filter on not\_analyzed field with case insensitive filter.  
i think i have 3 options:

1. reindex with another mapping
2. use script filter
3. query\_string filter

i've edited the original post, with what exactly doesnt work

---

<div class="post-metadata">

### Author: ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)
#### Post date: [January 27, 2016, 12:31pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/4 "2016-01-27T12:31:57Z")

</div>

Can you please give us your mapping?

The `query_string` query can be very trappy, I personally prefer to use a combination of`bool`, `match` or `term` queries.

Also, do you have control over the possible values for `country` and `device` fields? It looks like to me that the values come from a predefined set of values (maybe a drop down list in a web form?) If so, why not using `term` queries directly?

---

<div class="post-metadata">

### Author: ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)
#### Post date: [January 27, 2016, 12:39pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/5 "2016-01-27T12:39:54Z")

</div>

```
"country": {
              "type": "string",
              "index": "not_analyzed",
              "doc_values": true
           },

```

country and device are indeed lists, but there are more fields that are not predefined, with long list of values.  
if i want to reindex, with new mapping, can i keep somehow the original values, and also have the ability to search case-insensitive search?

---

<div class="post-metadata">

### Author: ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)
#### Post date: [January 27, 2016, 12:41pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/6 "2016-01-27T12:41:58Z")

</div>

> [@liorg2](#):
>
> if i want to reindex, with new mapping, can i keep somehow the original values, and also have the ability to search case-insensitive search?

Yes, see [https://www.elastic.co/guide/en/elasticsearch/reference/2.1/\_multi\_fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/_multi_fields.html)

---

<div class="post-metadata">

### Author: ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)
#### Post date: [January 27, 2016, 12:43pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/7 "2016-01-27T12:43:54Z")

</div>

it starts with **"Multi-fields are dead!"** 🙂

---

<div class="post-metadata">

### Author: ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)
#### Post date: [January 27, 2016, 12:51pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/8 "2016-01-27T12:51:24Z")

</div>

Yes, the feature has been renamed into `fields` 🙂 I linked to the breaking change page but the link to the document is: [https://www.elastic.co/guide/en/elasticsearch/reference/2.1/multi-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/multi-fields.html)

---

<div class="post-metadata">

### Author: ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)
#### Post date: [January 27, 2016, 12:57pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/9 "2016-01-27T12:57:57Z")

</div>

thanks a lot man

---

<div class="post-metadata">

### Author: ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)
#### Post date: [January 27, 2016, 1:07pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/10 "2016-01-27T13:07:21Z")

</div>

You're welcome 🙂

---

<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 5, 2017, 11:21pm UTC](https://discuss.elastic.co/t/query-string-filter-syntax-bug-v1-7/40215/11 "2017-07-05T23:21:06Z")

</div>


