import asyncio from applications.api import AsyncElasticSearchClient async def get_crawler_task(): async with AsyncElasticSearchClient() as client: # await client.es.indices.put_mapping( # index="meta_articles_v1", # body={ # "properties": { # "status": { # "type": "integer", # } # } # } # ) await client.es.update_by_query( index="meta_articles_v1", body={ "script": { "source": "ctx._source.status = params.default", "lang": "painless", "params": {"default": 1}, }, "query": { # 只改那些还没有 status 的 "bool": {"must_not": [{"exists": {"field": "status"}}]} }, "conflicts": "proceed", }, ) print("success") if __name__ == "__main__": asyncio.run(get_crawler_task())