# Boolean parameters in token filters are stringified, breaking elasticsearch\_dsl analysis comparison

**URL:** <https://discuss.elastic.co/t/boolean-parameters-in-token-filters-are-stringified-breaking-elasticsearch-dsl-analysis-comparison/260342>\
**Category:** Elasticsearch\
**Created:** [January 6, 2021, 12:59pm UTC](https://discuss.elastic.co/t/boolean-parameters-in-token-filters-are-stringified-breaking-elasticsearch-dsl-analysis-comparison/260342 "2021-01-06T12:59:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeoMcA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leomca/32/81831_2.png) [@LeoMcA](https://discuss.elastic.co/u/LeoMcA)\
**Post date:** [January 6, 2021, 12:59pm UTC](https://discuss.elastic.co/t/boolean-parameters-in-token-filters-are-stringified-breaking-elasticsearch-dsl-analysis-comparison/260342/1 "2021-01-06T12:59:50Z")

</div>

Heya, I'm not sure if this is a bug with elastic itself or with the elasticsearch\_dsl python library, so posting here before filing an issue on github.

If you set up a token filter with a boolean parameter, that parameter gets stringified:

```auto
PUT test
{
  "settings": {
    "analysis": {
      "filter": {
        "test": {
          "ignore_case": true,
          "type": "stop",
          "stopwords": [
            "h",
            "n",
            "t"
          ]
        }
      },
      "analyzer": {
        "test": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "test"
          ]
        }
      }
    }
  }
}

GET test/_settings
{
  "test" : {
    "settings" : {
      "index" : {
        "number_of_shards" : "1",
        "provided_name" : "test",
        "creation_date" : "1609856872062",
        "analysis" : {
          "filter" : {
            "test" : {
              "ignore_case" : "true",
              "type" : "stop",
              "stopwords" : [
                "h",
                "n",
                "t"
              ]
            }
          },
          "analyzer" : {
            "test" : {
              "filter" : [
                "test"
              ],
              "type" : "custom",
              "tokenizer" : "standard"
            }
          }
        },
        "number_of_replicas" : "1",
        "uuid" : "ebu4gTVqRbW6dEgleJCECA",
        "version" : {
          "created" : "7100099"
        }
      }
    }
  }
}

```

You'll notice `"ignore_case": true,` becomes `"ignore_case" : "true",`.

The filter does work as intended, however, elasticsearch\_dsl trips over this type change:

```auto
from elasticsearch_dsl import Document, analyzer, token_filter, Text

class ExampleDocument(Document):
    class Index:
        name = "test2"
        using = "es7_default"

    test = Text(
        analyzer=analyzer(
            "test",
            tokenizer="standard",
            filter=[
                token_filter("test", ignore_case=True, type="stop", stopwords=["h", "n", "t"]),
            ],
        )
    )

```

Running `ExampleDocument.init()` the first time succeeds, however running it again results in:

```auto
/vendor/elasticsearch_dsl/index.py in save(self, using)
    320 for k in analysis[section]
    321 ):
--> 322 raise IllegalOperation(
    323 "You cannot update analysis configuration on an open index, "
    324 "you need to close index %s first." % self._name

```

This error is thrown because, a few lines above, this check is made, and fails:

> <https://github.com/elastic/elasticsearch-dsl-py/blob/2087f46/elasticsearch_dsl/index.py#L317-L318>

Where:

```auto
existing_analysis.get(section, {}).get(k, None) == "true"
analysis[section][k] == True

```

So there's an easy workaround: changing `ignore_case=True` to `ignore_case="true"`. However, it seems like:

- either elasticsearch\_dsl should handle this (de)serialization properly, or
- elasticsearch itself shouldn't change the type of the boolean parameter

---

<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 3, 2021, 12:59pm UTC](https://discuss.elastic.co/t/boolean-parameters-in-token-filters-are-stringified-breaking-elasticsearch-dsl-analysis-comparison/260342/2 "2021-02-03T12:59:57Z")

</div>

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