1

カスタマイズされたインデックス (10 個のシャード) を作成してからドキュメントを追加するために、次のようなことを試しました。

  from elasticsearch_dsl import DocType, Index, String, Analyzer, token_filter


  class User(DocType):
        class Meta:
            index = 'test_index'

        name = String(required=True, analyzer=analyzer(
                    'german_analyzer',
                    tokenizer="standard",
                    filter=["standard",
                            "lowercase",
                            token_filter('german_snowball',
                                         type='snowball',
                                         language='German'),
                            token_filter('german_excluded_words',
                                         type='stop',
                                         stopwords='_german_')
                    ]))

    current_index = Index('test_index')
    # Set default settings:
    current_index.settings(number_of_shards=10)
    # Delete the index or ignore if it doesn't exist.
    current_index.delete(ignore=404)
    # Execute the request (Create Index)
    current_index.create()

    # Add document:
    User.init()
    user = User(name= 'Jaime Williams')
    user.meta.id = 1
    user.save()

しかし、次のエラーが発生します。 elasticsearch_dsl.exceptions.IllegalOperation: You cannot update analysis configuration on an open index, you need to close index test_index first.

カスタマイズされた数のシャードでインデックスを作成し、それにドキュメントを追加する方法はありますか?

4

0 に答える 0