def ingest_to_index(): """ Ingests all products into the index. Does some preprocessing before hand. :return: """ es = get_connection_from_env() with open("../../meta_Clothing_Shoes_and_Jewelry.json") as myfile: while next(myfile): head = [eval(next(myfile)) for x in range(50000)] parsed = [ dict(_preprocess_product(pr), **{"_index": INDEX}) for pr in head if pr.get("description") ] print(bulk(es, parsed))
:return: """ es = get_connection_from_env() with open("../../meta_Clothing_Shoes_and_Jewelry.json") as myfile: while next(myfile): head = [eval(next(myfile)) for x in range(50000)] parsed = [ dict(_preprocess_product(pr), **{"_index": INDEX}) for pr in head if pr.get("description") ] print(bulk(es, parsed)) if __name__ == '__main__': es = get_connection_from_env() delete_index_by_name(es_connection=es, index=INDEX) ingest_to_index() print("Done") # def store_old_brand_value(): # """ # Creates a new field for all articles named "old_brand" containing the old value of the "brand" field. # """ # es = get_connection_from_env() # n_results = 1 # # while n_results > 0: # results = execute_query(es_connection=es, # query=query, # index=INDEX)