I am new to Elasticsearch and using  6.7
I am trying to make a text field aggregatabe in an existing index.
type": "action_request_validation_exception", 
"reason": "Validation Failed: 1: mapping type is missing;"
PUT /my_index/_mappings
{
		"properties": {
		  "_doc":{
		  "colType": {
			"type": "text",
			"fields": {
			  "keyword": { 
				"type":  "keyword"
			  }
			}
		  }
		}
		}
} 
             
            
               
               
               
            
            
           
          
            
            
              Can you try with:
PUT /my_index/_mapping/_doc
{
		"properties": {
		  "colType": {
			"type": "text",
			"fields": {
			  "keyword": { 
				"type":  "keyword"
			  }
			}
		  }
	}
}
 
Documentation 
Please be aware you need to reindex.
Sorry for the formatting, I am on mobile.
             
            
               
               
              1 Like 
            
            
           
          
            
            
              
Thank you for the quick respone , but now I get this error . 
Mapper for [colType] conflicts with existing mapping in other types:\n[mapper [colType] has different [analyzer]]
Just to add analyze is defined as "keyword" for this field.
             
            
               
               
               
            
            
           
          
            
            
              Can you share the output of GET my_index?
             
            
               
               
               
            
            
           
          
            
            
              { 
"test" : { 
"aliases" : { }, 
"mappings" : { 
"_doc" : { 
"properties" : { 
"colType" : { 
"type" : "text", 
"analyzer" : "keyword" 
}, 
"field1" : { 
"type" : "text", 
"fields" : { 
"keyword" : { 
"type" : "keyword" 
} 
} 
} 
} 
} 
}, 
"settings" : { 
"index" : { 
"creation_date" : "1587762638106", 
"number_of_shards" : "1", 
"number_of_replicas" : "1", 
"uuid" : "xxxxxxxxxxx",  // masked the UUID 
"version" : { 
"created" : "6070099" 
}, 
"provided_name" : "test" 
} 
} 
} 
}
             
            
               
               
               
            
            
           
          
            
            
              Thanks!
So you can use:
PUT /test/_mapping/_doc
{
  "properties": {
    "colType": {
      "type": "text",
      "analyzer": "keyword",
      "fields": {
        "keyword": {
          "type": "keyword"
        }
      }
    }
  }
}
 
BUT you will need to update all the documents in the index to be sure the documents get the colType.keyword field filled.
If your index hasn't a lot of documents you can proceed with:
POST test/_update_by_query
{
  "query": {
    "match_all": {}
  }
}
 
If the index is huge, it might be preferable to do a reindex into another index .
If you're using Kibana, do not forget to refresh your index pattern.
             
            
               
               
               
            
            
           
          
            
            
              This solved my problem . Thanks for the help
             
            
               
               
              1 Like 
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    May 23, 2020,  7:56pm
                   
                   
              8 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.