adityosn  
                (Adityo Setyonugroho)
               
                 
                 
              
                  
                    March 14, 2018,  9:44am
                   
                   
              1 
               
             
            
              Hi,
I would like adding data to my new added properties. So, I have ran mapping again to update my last index mapping by adding this property:
"author": { 
      "properties": {
        "id":  { "type": "integer" },
        "name": { 
          "properties": {
            "nicename": { "type": "text" },
            "displayname":  { "type": "text" }
          }
        },
		"email":  { "type": "text" }
      }
 
After I add new properties to my index, I would like to adding this part of properties data without reimport all my other properties data.
For example beside author properties I have:
Post ID 
Post Content 
Post Date 
 
I have run UPDATE API from elastic by using this : 
http://esURL/index/type/idcontent/_update      POST
   {
      "script": {
        "source": "ctx._source.author.id = '10'",
        "lang": "painless"
      }
    }
 
I got this error:
Any Idea how to do it ?
Thank You
             
            
               
               
               
            
            
           
          
            
              
                jpountz  
                (Adrien Grand)
               
              
                  
                    March 14, 2018,  9:56am
                   
                   
              2 
               
             
            
              What does your document look like before the update? Does it actually exsist? Does it have an author field which is an object?
             
            
               
               
               
            
            
           
          
            
              
                adityosn  
                (Adityo Setyonugroho)
               
              
                  
                    March 14, 2018, 10:03am
                   
                   
              3 
               
             
            
              Hi,
Thank you for your reply.
It does not exists before, I would like to update my document by just adding author without I need to add again ID, Content, and Date.
For example, I have this before mapping:
{
    "post_ID" : 8,
    "post_date" : 1405461244000,
    "post_content" : "CONTENT SAMPLE"
  }
 
Then, after mapping, I would like to add author data to my document, so become like this:
{
	"author" : {
		"email" : "user@email.com",
		"id" : 1,
		"name" : {
			"nicename" : "user",
			"displayname" : "user"
		}
	}
    "post_ID" : 8,
    "post_date" : 1405461244000,
    "post_content" : "CONTENT SAMPLE"
  } 
             
            
               
               
               
            
            
           
          
            
              
                jpountz  
                (Adrien Grand)
               
              
                  
                    March 14, 2018, 10:45am
                   
                   
              4 
               
             
            
            
               
               
               
            
            
           
          
            
              
                adityosn  
                (Adityo Setyonugroho)
               
              
                  
                    March 14, 2018,  1:06pm
                   
                   
              5 
               
             
            
              Thank you so much ! Yes, I can insert object type into my created document.
By using : https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_literal_doc_as_upsert_literal 
Thanks a lot
Best Regards,
Adityo Setyonugroho
             
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    April 11, 2018,  1:07pm
                   
                   
              6 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.