original_docstring: 
          Create or update an entity.
  
          
docstring: Create or update an entity.
docstring_tokens: Create or update an entity .
code: def replace(self, identifier, new_instance, **kwargs):
          """
          Create or update an entity.
  
          """
          now_millis = self.new_timestamp()
  
          if new_instance.id is None:
              if identifier is None:
                  identifier = self.new_object_id()
              new_instance.id = identifier
  
          if new_instance.created_at is None:
              new_instance.created_at = now_millis
  
          new_instance._id = new_instance.id
          new_instance.updated_at = now_millis
  
          new_instance.save(
              id=new_instance.id,
              using=self.elasticsearch_client,
              index=self.get_index_name(**kwargs),
              validate=True,
          )
          return new_instance
code_tokens: def replace ( self , identifier , new_instance , ** kwargs ) : now_millis = self . new_timestamp ( ) if new_instance . id is None : if identifier is None : identifier = self . new_object_id ( ) new_instance . id = identifier if new_instance . created_at is None : new_instance . created_at = now_millis new_instance . _id = new_instance . id new_instance . updated_at = now_millis new_instance . save ( id = new_instance . id , using = self . elasticsearch_client , index = self . get_index_name ( ** kwargs ) , validate = True , ) return new_instance
short_docstring: Create or update an entity.
short_docstring_tokens: Create or update an entity .
comment: """
          Create or update an entity.
  
          """