# Updating index.max\_shingle\_diff

**URL:** <https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937>\
**Category:** Elasticsearch\
**Created:** [July 5, 2022, 3:52pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937 "2022-07-05T15:52:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin1/32/100671_2.png) [@Benjamin1](https://discuss.elastic.co/u/Benjamin1)\
**Post date:** [July 5, 2022, 3:52pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937/1 "2022-07-05T15:52:23Z")

</div>

When I try to create an index I get this message:

ServerError: Type: illegal\_argument\_exception Reason: "In Shingle TokenFilter the difference between max\_shingle\_size and min\_shingle\_size (and +1 if outputting unigrams) must be less than or equal to: [3] but was [4]. This limit can be set by changing the [index.max\_shingle\_diff] index level setting."

How can I update index.max\_shingle\_diff ?

I tried  
http:///\_all/\_settings

```auto
{
    "index" : {
        "max_shingle_diff" : 10
    }
}

```

But gives:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "index_not_found_exception",
        "reason": "no such index [null] and no indices exist",
        "resource.type": "index_expression",
        "resource.id": "_all"
      }
    ],
    "type": "index_not_found_exception",
    "reason": "no such index [null] and no indices exist",
    "resource.type": "index_expression",
    "resource.id": "_all"
  },
  "status": 404
}

```

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [July 5, 2022, 5:07pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937/2 "2022-07-05T17:07:45Z")

</div>

Hi @Benjamin1

Try this:

```auto
PUT INDEX_NAME/_settings
{
    "index" : {
        "max_shingle_diff" : 10
    }
}

```

---

<div class="post-metadata">

**Author:** ![Benjamin1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin1/32/100671_2.png) [@Benjamin1](https://discuss.elastic.co/u/Benjamin1)\
**Post date:** [July 5, 2022, 7:25pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937/3 "2022-07-05T19:25:36Z")

</div>

Hi @RabBit_BR  
What should I put for INDEX\_NAME ? I have no index created. I get the error message when I try to create new index.

ServerError: Type: illegal\_argument\_exception Reason: "In Shingle TokenFilter the difference between max\_shingle\_size and min\_shingle\_size (and +1 if outputting unigrams) must be less than or equal to: [3] but was [4]. This limit can be set by changing the [index.max\_shingle\_diff] index level setting."

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [July 5, 2022, 8:39pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937/4 "2022-07-05T20:39:57Z")

</div>

Sorry, I thought the index already existed.

Well I believe you will need to change the max\_shingle\_diff in phases.

First I created the index in the valid range (ex: min=2 and max=3), then you will close the index and run the command I mentioned above, change the index\_name to the name of the index you created.  
Now you will run the command to update the \_setting with the shingle interval you want.  
Then you will open the index.

```auto
Create Index
PUT /my-index-000001
{
  "settings": {
    "analysis": {
      "analyzer": {
        "en": {
          "tokenizer": "standard",
          "filter": ["my_shingle_filter"]
        }
      },
      "filter": {
        "my_shingle_filter": {
          "type": "shingle",
          "min_shingle_size": 2,
          "max_shingle_size": 3,
          "output_unigrams": false
        }
      }
    }
  }
}

Close Index
POST my-index-000001/_close

Change Max Shingle Diff
PUT my-index-000001/_settings
{
    "index" : {
        "max_shingle_diff" : 8
    }
}

Update Shingle Max Min Size
PUT my-index-000001/_settings
{
  "analysis": {
    "analyzer": {
      "en": {
        "tokenizer": "standard",
        "filter": [
          "my_shingle_filter"
        ]
      }
    },
    "filter": {
      "my_shingle_filter": {
        "type": "shingle",
        "min_shingle_size": 2,
        "max_shingle_size": 6,
        "output_unigrams": false
      }
    }
  }
}

Open Index
POST my-index-000001/_open

```

---

<div class="post-metadata">

**Author:** ![Benjamin1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin1/32/100671_2.png) [@Benjamin1](https://discuss.elastic.co/u/Benjamin1)\
**Post date:** [July 5, 2022, 9:12pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937/5 "2022-07-05T21:12:47Z")

</div>

Hi @RabBit_BR  
Thanks.

I found easier way.

During index creation:

```auto
PUT /test
{
  "settings": {
    "number_of_shards": 1,
     "max_shingle_diff" : 10
  },
  "mappings": {
    "properties": {
      "field1": { "type": "text" }
    }
  }
}

```

---

<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:** [August 2, 2022, 9:13pm UTC](https://discuss.elastic.co/t/updating-index-max-shingle-diff/308937/6 "2022-08-02T21:13:35Z")

</div>

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