def create_search_item(auth_params, func_params): """ This function is used to create, or update if already exists, an item on elasticsearch :param auth_params: Input parameters of the function that generate this function call :param func_params: Output parameters of the function that generate this function call """ token = auth_params['token'] keywords_resp = get_keyword_by_item(func_params['id'], token) people = get_person_by_item(func_params['id'], token) keywords = [] for k in keywords_resp: keywords.append(k['description']) func_params['keywords'] = keywords + people del func_params['thumb'] del func_params['preview'] exists = exists_index(func_params, token) exists = exists.json() #if exists['results']: if 'results' in exists: update_index(func_params, token) else: create_index(func_params, token)
def delete_search_item(auth_params, func_params): """ This function is used to delete an item on elasticsearch :param auth_params: Input parameters of the function that generate this function call :param func_params: Output parameters of the function that generate this function call """ token = auth_params['token'] exists = exists_index(func_params, token) exists = exists.json() if exists['results']: delete_index(func_params, token)