What is the Elasticsearch-py equivalent to alias actions?

后端 未结 2 1928
囚心锁ツ
囚心锁ツ 2021-02-13 16:30

I am trying to implement multiples indices approach using elasticsearch-dsl. There are basically two steps:

1. Create aliases:

PUT /twee         


        
2条回答
  •  灰色年华
    2021-02-13 16:55

    To implement that you need to use elasticsearch-py:

    from elasticsearch import Elasticsearch
    es = Elasticsearch()
    
    # use es.indices instead of instantiating IndicesClient
    es.indices.put_alias(index='tweets_1', name='tweets_search')
    es.indices.put_alias(index='tweets_1', name='tweets_index')
    
    es.indices.update_aliases({
      "actions": [
        { "add":    { "index": "tweets_2", "alias": "tweets_search" }}, 
        { "remove": { "index": "tweets_1", "alias": "tweets_index"  }}, 
        { "add":    { "index": "tweets_2", "alias": "tweets_index"  }}  
      ]
    })
    

提交回复
热议问题