How to make String Field to Non Analyzed?

I am trying to Make String Field Analyzed to non-analyzed. But I am unable to make the string field the non-analyzed. My String field Hostname look like "q-gp2-qadebug-1". Please help me out how to make it non-analyzed.
I am using Elasticsearch 5.2.2

Please find the below template, I am using.

curl -XPUT 'http://localhost:9200/_template/elasticsearchstats' -d '{
"template": "elasticsearchstats",
"order": 10,
"settings": {
"index.refresh_interval": "5s"
},
"mappings": {
"default": {
"_all": {
"enabled": true,
"omit_norms": true
},
"dynamic_templates": [
{
"string_fields": {
"match": "",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
},
{
"float_fields": {
"match": "
",
"match_mapping_type": "float",
"mapping": {
"type": "float",
"doc_values": true
}
}
},
{
"double_fields": {
"match": "",
"match_mapping_type": "double",
"mapping": {
"type": "double",
"doc_values": true
}
}
},
{
"byte_fields": {
"match": "
",
"match_mapping_type": "byte",
"mapping": {
"type": "byte",
"doc_values": true
}
}
},
{
"short_fields": {
"match": "",
"match_mapping_type": "short",
"mapping": {
"type": "short",
"doc_values": true
}
}
},
{
"integer_fields": {
"match": "
",
"match_mapping_type": "integer",
"mapping": {
"type": "integer",
"doc_values": true
}
}
},
{
"long_fields": {
"match": "",
"match_mapping_type": "long",
"mapping": {
"type": "long",
"doc_values": true
}
}
},
{
"date_fields": {
"match": "
",
"match_mapping_type": "date",
"mapping": {
"type": "date",
"doc_values": true
}
}
},
{
"geo_point_fields": {
"match": "*",
"match_mapping_type": "geo_point",
"mapping": {
"type": "geo_point",
"doc_values": true
}
}
}
],
"properties": {
"@timestamp": {
"type": "date",
"doc_values": true
},
"@version": {
"type": "string",
"index": "not_analyzed",
"doc_values": true
},
"clusterstatus" : {
"type" : "long"
},
"cpupercent" : {
"type" : "long"
},
"fielddataestimated" : {
"type" : "long"
},
"fielddatalimit" : {
"type" : "long"
},
"freedisk" : {
"type" : "long"
},
"currentstatus" : {
"type" : "string",
"index" : "not_analyzed"
},
"hostname" : {
"type": "keyword",
"index" : "no"
},
"testname" : {
"type": "keyword"
},
"freemem" : {
"type" : "long"
},
"heapold" : {
"type" : "long"
},
"heapsurvior" : {
"type" : "long"
},
"heapused" : {
"type" : "long"
},
"heapyoung" : {
"type" : "long"
},
"loadaverage" : {
"type" : "long"
},
"hostname" : {
"type" : "string"
},
"openfiles" : {
"type" : "float"
},
"threadcount" : {
"type" : "float"
},
"type" : {
"type" : "string"
},
"geoip": {
"type": "object",
"dynamic": true,
"properties": {
"ip": {
"type": "ip",
"doc_values": true
},
"location": {
"type": "geo_point",
"doc_values": true
},
"latitude": {
"type": "float",
"doc_values": true
},
"longitude": {
"type": "float",
"doc_values": true
}
}
}
}
}
}
}'

I am also tried to use string field as .raw in the below template, but the same result.

curl -XPUT 'http://localhost:9200/_template/elasticsearchstats' -d '{

"template": "elasticsearchstats",
"order": 10,
"settings": {
    "index.refresh_interval": "5s"
},
"mappings": {
    "_default_": {
        "_all": {
            "enabled": true,
            "omit_norms": true
        },
        "dynamic_templates": [
            {
                "string_fields": {
                    "match": "*",
                    "match_mapping_type": "string",
                    "mapping": {
                        "type": "keyword"
                    }
                }
            },
            {
                "float_fields": {
                    "match": "*",
                    "match_mapping_type": "float",
                    "mapping": {
                        "type": "float",
                        "doc_values": true
                    }
                }
            },
            {
                "double_fields": {
                    "match": "*",
                    "match_mapping_type": "double",
                    "mapping": {
                        "type": "double",
                        "doc_values": true
                    }
                }
            },
            {
                "byte_fields": {
                    "match": "*",
                    "match_mapping_type": "byte",
                    "mapping": {
                        "type": "byte",
                        "doc_values": true
                    }
                }
            },
            {
                "short_fields": {
                    "match": "*",
                    "match_mapping_type": "short",
                    "mapping": {
                        "type": "short",
                        "doc_values": true
                    }
                }
            },
            {
                "integer_fields": {
                    "match": "*",
                    "match_mapping_type": "integer",
                    "mapping": {
                        "type": "integer",
                        "doc_values": true
                    }
                }
            },
            {
                "long_fields": {
                    "match": "*",
                    "match_mapping_type": "long",
                    "mapping": {
                        "type": "long",
                        "doc_values": true
                    }
                }
            },
            {
                "date_fields": {
                    "match": "*",
                    "match_mapping_type": "date",
                    "mapping": {
                        "type": "date",
                        "doc_values": true
                    }
                }
            },
            {
                "geo_point_fields": {
                    "match": "*",
                    "match_mapping_type": "geo_point",
                    "mapping": {
                        "type": "geo_point",
                        "doc_values": true
                    }
                }
            }
        ],
        "properties": {
            "@timestamp": {
                "type": "date",
                "doc_values": true
            },
            "@version": {
                "type": "string",
                "index": "not_analyzed",
                "doc_values": true
            },
            "clusterstatus" : {
        "type" : "long"
      },
      "cpupercent" : {
        "type" : "long"
      },
      "fielddataestimated" : {
        "type" : "long"
      },
      "fielddatalimit" : {
        "type" : "long"
      },
      "freedisk" : {
        "type" : "long"
      },
      "currentstatus" : {
        "type" : "text",
        "fields": {
        "raw": {
          "type":  "keyword"
        }
      }
      },
      "hostname" : {
        "type": "text",
        "fields": {
        "raw": {
          "type":  "keyword"
        }
      }
        },
      "testname" : {
        "type": "keyword"
      },
      "freemem" : {
        "type" : "long"
      },
      "heapold" : {
        "type" : "long"
      },
      "heapsurvior" : {
        "type" : "long"
      },
      "heapused" : {
        "type" : "long"
      },
      "heapyoung" : {
        "type" : "long"
      },
      "loadaverage" : {
        "type" : "long"
      },
      "hostname" : {
        "type" : "string"
      },
      "openfiles" : {
        "type" : "float"
      },
      "threadcount" : {
        "type" : "float"
      },
      "type" : {
        "type" : "string"
      },
      "geoip": {
                "type": "object",
                "dynamic": true,
                "properties": {
                    "ip": {
                        "type": "ip",
                        "doc_values": true
                    },
                    "location": {
                        "type": "geo_point",
                        "doc_values": true
                    },
                    "latitude": {
                        "type": "float",
                        "doc_values": true
                    },
                    "longitude": {
                        "type": "float",
                        "doc_values": true
                    }
                }
            }
        }
    }
}

}'

Did you delete your index?

What is your actual mapping ?

yes, I Delete the index.....

My mappings are

"template": "elasticsearchstats",
"order": 10,
"settings": {
"index.refresh_interval": "5s"
},
"mappings": {
"default": {
"_all": {
"enabled": true,
"omit_norms": true
},
"dynamic_templates": [
{
"string_fields": {
"match": "",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
},
{
"float_fields": {
"match": "
",
"match_mapping_type": "float",
"mapping": {
"type": "float",
"doc_values": true
}
}
},
{
"double_fields": {
"match": "",
"match_mapping_type": "double",
"mapping": {
"type": "double",
"doc_values": true
}
}
},
{
"byte_fields": {
"match": "
",
"match_mapping_type": "byte",
"mapping": {
"type": "byte",
"doc_values": true
}
}
},
{
"short_fields": {
"match": "",
"match_mapping_type": "short",
"mapping": {
"type": "short",
"doc_values": true
}
}
},
{
"integer_fields": {
"match": "
",
"match_mapping_type": "integer",
"mapping": {
"type": "integer",
"doc_values": true
}
}
},
{
"long_fields": {
"match": "",
"match_mapping_type": "long",
"mapping": {
"type": "long",
"doc_values": true
}
}
},
{
"date_fields": {
"match": "
",
"match_mapping_type": "date",
"mapping": {
"type": "date",
"doc_values": true
}
}
},
{
"geo_point_fields": {
"match": "*",
"match_mapping_type": "geo_point",
"mapping": {
"type": "geo_point",
"doc_values": true
}
}
}
],

You have Hostname in there twice.

Thanks. It is working now

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