Set default to not_analyzed

hi, there,

I know ES default setting is "analyzed", how to set it to "not_analyzed", 'cause I want to try term-search with most of my fields.

Thanks,
Dennis

You can define an index template with a dynamic template which sets that to not_analyzed.

Thanks, David

I tried with your guide, but ES is working really strange.

I tied the following template, and assuming any string value in any type in i2 index, is not_analized, but it's not (some are not_analized while some are analized)
What I want is: any new string-value field in any type in i2 index, is not_analized.

curl -XPUT 'localhost:8200/i2?pretty' -d'
{
  "mappings": {
    "t2": {
      "dynamic_templates": [
        {
          "strings": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        }
      ]
    }
  }
}'

curl -X GET "localhost:8200/i2/_mapping?pretty"

curl -X PUT "http://localhost:8200/i2/t2/1?pretty" -d '{"first_name":"John","age":25,"interests":[{"name":"sports","level":"A"},{"name":"music","level":"B"}]}'
curl -X PUT "http://localhost:8200/i2/form1/2?pretty" -d '{"first_name":"Jim","age":28,"interests":[{"name":"water","level":"A"},{"name":"dive","level":"B"}]}'
curl -X PUT "http://localhost:8200/i2/t2/3?pretty" -d '{"a":"xyz"}'
curl -X PUT "http://localhost:8200/i2/form1/3?pretty" -d '{"a":"xyz"}'
curl -X PUT "http://localhost:8200/i2/form1/3?pretty" -d '{"p1":"xyz"}'
curl -X POST "http://localhost:8200/i2/t2/?pretty" -d '{"ccc":"xyz"}'
curl -X POST "http://localhost:8200/i2/t2/?pretty" -d '{"dddd":"xyz"}'
curl -X PUT "http://localhost:8200/i2/t2/100?pretty" -d '{"f2":"xyz"}'

curl -X PUT "http://localhost:8200/i2/form1/3?pretty" -d '{"a":"xyz"}'
curl -X PUT "http://localhost:8200/i2/t2/100?pretty" -d '{"ccc":"xyz"}'
curl -X PUT "http://localhost:8200/i2/t2/100?pretty" -d '{"xyz":"xyz"}'

curl -X POST "http://localhost:8200/i2/form1/?pretty" -d '{"q1":"123"}'
curl -X POST "http://localhost:8200/i2/ttt3/?pretty" -d '{"first_name":"123"}'



work@dev01.dev01:~/softwares/elasticsearch-2.3.5/ curl -X GET "localhost:8200/i2/_mapping?pretty"
{
  "i2" : {
    "mappings" : {
      "ttt3" : {
        "properties" : {
          "first_name" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "qwer" : {
            "type" : "string"
          }
        }
      },
      "t2" : {
        "dynamic_templates" : [ {
          "strings" : {
            "mapping" : {
              "index" : "not_analyzed",
              "type" : "string"
            },
            "match_mapping_type" : "string"
          }
        } ],
        "properties" : {
          "a" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "age" : {
            "type" : "long"
          },
          "ccc" : {
            "type" : "string"
          },
          "dddd" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "e1" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "f2" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "first_name" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "interests" : {
            "properties" : {
              "level" : {
                "type" : "string",
                "index" : "not_analyzed"
              },
              "name" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          },
          "xyz" : {
            "type" : "string",
            "index" : "not_analyzed"
          }
        }
      },
      "form1" : {
        "properties" : {
          "a" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "age" : {
            "type" : "long"
          },
          "ccc" : {
            "type" : "string"
          },
          "first_name" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "interests" : {
            "properties" : {
              "level" : {
                "type" : "string",
                "index" : "not_analyzed"
              },
              "name" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          },
          "p1" : {
            "type" : "string"
          },
          "q1" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

The answer is default mapping
:slight_smile:

Dinnis