parameters: (data)
return_statement: return action, data.get('_source', data)
docstring: From one document or action definition passed in by the user extract the
      action/data lines needed for elasticsearch's
      :meth:`~elasticsearch.Elasticsearch.bulk` api.
docstring_summary: From one document or action definition passed in by the user extract the
      action/data lines needed for elasticsearch's
      :meth:`~elasticsearch.Elasticsearch.bulk` api.
docstring_tokens: From one document or action definition passed in by the user extract the action / data lines needed for elasticsearch s : meth : ~elasticsearch . Elasticsearch . bulk api .
function: def expand_action(data):
      """
      From one document or action definition passed in by the user extract the
      action/data lines needed for elasticsearch's
      :meth:`~elasticsearch.Elasticsearch.bulk` api.
      """
      # when given a string, assume user wants to index raw json
      if isinstance(data, string_types):
          return '{"index":{}}', data
  
      # make sure we don't alter the action
      data = data.copy()
      op_type = data.pop('_op_type', 'index')
      action = {op_type: {}}
      for key in ('_index', '_parent', '_percolate', '_routing', '_timestamp',
                  '_type', '_version', '_version_type', '_id',
                  '_retry_on_conflict', 'pipeline'):
          if key in data:
              action[op_type][key] = data.pop(key)
  
      # no data payload for delete
      if op_type == 'delete':
          return action, None
  
      return action, data.get('_source', data)
function_tokens: def expand_action ( data ) : # when given a string, assume user wants to index raw json if isinstance ( data , string_types ) : return '{"index":{}}' , data # make sure we don't alter the action data = data . copy ( ) op_type = data . pop ( '_op_type' , 'index' ) action = { op_type : { } } for key in ( '_index' , '_parent' , '_percolate' , '_routing' , '_timestamp' , '_type' , '_version' , '_version_type' , '_id' , '_retry_on_conflict' , 'pipeline' ) : if key in data : action [ op_type ] [ key ] = data . pop ( key ) # no data payload for delete if op_type == 'delete' : return action , None return action , data . get ( '_source' , data )