# Query\_string, lenient and boolean values

**URL:** <https://discuss.elastic.co/t/query-string-lenient-and-boolean-values/72918>\
**Category:** Elasticsearch\
**Created:** [January 26, 2017, 3:45pm UTC](https://discuss.elastic.co/t/query-string-lenient-and-boolean-values/72918 "2017-01-26T15:45:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pruyne](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pruyne](https://discuss.elastic.co/u/pruyne)\
**Post date:** [January 26, 2017, 3:45pm UTC](https://discuss.elastic.co/t/query-string-lenient-and-boolean-values/72918/1 "2017-01-26T15:45:01Z")

</div>

I'm running on ES 5.1.2 currently, though I've seen this behavior on 2.x versions as well:

When I have an index with a mapping containing a `boolean` datatype, it seems that when executing a `query_string` or `simple_query_string` query with `"lenient": true`, all items that have values which are Truthy (as defined as they opposite of Falsey per [Boolean datatype](https://www.elastic.co/guide/en/elasticsearch/reference/current/boolean.html)) will match.

Example mapping:

```auto
{
  "index": {
    "mappings": {
      "properties": {
        "string_val": {
          "type": "string"
        },
        "bool_val": {
          "type": "boolean"
        }
      }
    }
  }
}

```

Example `query_string` query:

```auto
{
  "query": {
    "query_string": {
      "fields": ["string_val", "bool_val"],
      "lenient": true,
      "query": "An Arbitrary String"
    }
  }
}

```

This will match all documents for which `bool_val` has the value `true`.

I see the dilemma of how to treat such a query with the use of `"lenient": true`, however, particularly as the note in the above referenced page on boolean datatypes I would have hoped that as of 5.1.1 that query string would match neither true nor false values for the boolean field.

Unfortunately, in my full use case, I cannot restrict the query to particular fields, and thus I need lenient.

Any suggestions?

Thanks.

---

<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:** [February 23, 2017, 3:45pm UTC](https://discuss.elastic.co/t/query-string-lenient-and-boolean-values/72918/2 "2017-02-23T15:45:05Z")

</div>

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