title: Can you set a field to not_analyzed in an auto created index in Elasticsearch?
body: <p>As part of our AWS infrastructure, I am using an Elasticsearch (7.4) index. We use Terraform to create the domain in AWS Elasticsearch but we don't create the index explicitly. Instead when the first document is posted, the index is auto-created. This worked well, but now I have been given the requirement to have a non analyzed field (user id).</p>
  <p>Is there a way to make a field <code>not_analyzed</code> when putting the first document?</p>
  <p>If there is <strong>not</strong>, what are my options to set the field to <code>not_analyzed</code>? Should I do some sort of init/bootstrapping? Maybe there is a way to do it from Terraform. The application is build using Chalice and runs in Lambda. Not sure how to do initialization in Lambda in that case. Ideally I would fire this call a single time:</p>
  <pre><code>PUT /my_index
  {
      &quot;mappings&quot; : {
            &quot;properties&quot; : {
                &quot;user_id&quot; : {
                    &quot;type&quot; : &quot;string&quot;,
                    &quot;index&quot; : &quot;not_analyzed&quot; 
                }
            }
      }
  
  }
  </code></pre>
  <p>When restarting the application, this call would be send again but I guess it's immutable (PUT).</p>