docs: def add_upsert(self, action, meta_action, doc_source, update_spec):
          """
          Function which stores sources for "insert" actions
          and decide if for "update" action has to add docs to
          get source buffer
          """
  
          # Whenever update_spec is provided to this method
          # it means that doc source needs to be retrieved
          # from Elasticsearch. It means also that source
          # is not stored in local buffer
          if update_spec:
              self.bulk_index(action, meta_action)
  
              # -1 -> to get latest index number
              # -1 -> to get action instead of meta_action
              # Update document based on source retrieved from ES
              self.add_doc_to_update(action, update_spec, len(self.action_buffer) - 2)
          else:
              # Insert and update operations provide source
              # Store it in local buffer and use for comming updates
              # inside same buffer
              # add_to_sources will not be called for delete operation
              # as it does not provide doc_source
              if doc_source:
                  self.add_to_sources(action, doc_source)
              self.bulk_index(action, meta_action)