Jordan Savant # Software Engineer

Reset an Elastic Cluster with these Shell Command

Wipe out the instance

curl -u "$auth" -X DELETE "$endpoint"'?pretty' 2> /dev/null

Rebuild the instance with new settings

curl -u "$auth" -X PUT "$endpoint"'?pretty' -H 'Content-Type: application/json' -d'
{
  "settings": {
    "index.mapping.total_fields.limit": 10000,
    "analysis": {
      "analyzer": {
        "nodash": {
          "type": "custom",
          "tokenizer": "whitespace"
        },
        "lb_analyzer": {
          "tokenizer": "lb_tokenizer"
        }
      },
      "tokenizer": {
        "lb_tokenizer": {
          "type": "ngram",
          "min_gram": 3,
          "max_gram": 4,
          "token_chars": [
            "letter",
            "digit"
          ]
        }
      }
    }
  }
}
' 2> /dev/null

Shove the mappings back in

curl -u "$auth" -X PUT "$endpoint"'/_mapping?pretty' -H 'Content-Type: application/json' -d'
{
  "properties": {
    "legoBlockBuilder": {
      "enabled": false,
      "type": "object"
    },
    "siteSearchFeatured": {
      "type": "integer"
    },
    "type": {
      "type": "text",
      "analyzer": "nodash"
    },
    "content.title": {
      "type": "text",
      "fields": {
        "keywords": {
          "type": "keyword"
        },
        "ngrams": {
          "type": "text",
          "analyzer": "lb_analyzer"
        }
      }
    },
    "content.sharedContentTitle": {
      "type": "text",
      "fields": {
        "keywords": {
          "type": "keyword"
        },
        "ngrams": {
          "type": "text",
          "analyzer": "lb_analyzer"
        }
      }
    },
    "content.sharedContentCopy": {
      "type": "text",
      "fields": {
        "keywords": {
          "type": "keyword"
        },
        "ngrams": {
          "type": "text",
          "analyzer": "lb_analyzer"
        }
      }
    },
    "content.body": {
      "type": "text",
      "fields": {
        "keywords": {
          "type": "keyword"
        },
        "ngrams": {
          "type": "text",
          "analyzer": "lb_analyzer"
        }
      }
    }
  }
}
' 2> /dev/null