コード例 #1
0
def test_index_template_can_have_order():
    i = Index('i-*')
    it = i.as_template('i', order=2)

    assert {
        "index_patterns": ["i-*"],
        "order": 2
    } == it.to_dict()
コード例 #2
0
def test_index_template_can_have_order():
    i = Index('i-*')
    it = i.as_template('i', order=2)

    assert {
        "index_patterns": ["i-*"],
        "order": 2
    } == it.to_dict()
コード例 #3
0
def generate_template(index_name):
    """
    Generates the index template associated with the structure of the BuildResults
    document, allowing it to be uploaded to an ElasticSearch instance.

    Args:
        index_name: index name to generate the template with, should be the index the module will upload to
        output_file: (optional) file path to write template to
    """

    document = _BuildResultsMetaDocument()
    index = Index(name=index_name)
    index.document(document)
    index.settings(refresh_interval="30s",
                   number_of_shards="1",
                   number_of_replicas="1")
    index.aliases(**{index_name: {}})
    index_template = index.as_template(template_name="template_" + index_name,
                                       pattern="%s-*" % index_name)
    return index_template.to_dict()