我正在将数据索引到Elasticsearch中。
我不知道什么是“排序”。我没有将其放在映射中,也没有将其放在索引的数据中。
为什么会出现?
这是我的密码

def initialize_mapping(es):
    mapping_classification = {
        'properties': {
            '@timestamp': {'type': 'date'},
            'Labels': {'type': 'keyword'},
            'Model': {'type': 'keyword'},
            'Image': {'type': 'keyword'},
            'Time(ms)': {'type': 'short'},
            'Inference': {'type': 'text'},
            'Score': {'type': 'short'},
            'TPU_temp(°C)': {'type': 'short'}
        }
    }
    print("Initializing the mapping ...")
    if not es.indices.exists(INDEX_NAME):
        es.indices.create(INDEX_NAME)
        es.indices.put_mapping(body=mapping_classification, doc_type=DOC_TYPE, index=INDEX_NAME)



def main():

    es=initialize_elasticsearch()
    initialize_mapping(es)


    actions = [
        {
            '_index': INDEX_NAME,
            '_type': DOC_TYPE,
            "@timestamp": str(datetime.datetime.utcnow().strftime("%Y-%m-%d"'T'"%H:%M:%S")),
            "Labels": maX_group[0].split(":")[1],
            "Model": maX_group[1].split(":")[1],
            "Image": maX_group[2].split(":")[1],
            "Time(ms)": maX_group[4].split(":")[1],
            "Inference": maX_group[5].split(":")[1],
            "Score": maX_group[6].split(":")[1],
            "TPU_temp(°C)": maX_group[7].split(":")[1]

        }]



    try:
        res=helpers.bulk(client=es, index = INDEX_NAME, actions = actions)
        print ("\nhelpers.bulk() RESPONSE:", res)
        print ("RESPONSE TYPE:", type(res))

    except Exception as err:
        print("\nhelpers.bulk() ERROR:", err)


if __name__ == "__main__":
    main()

python - 为什么 “sort”出现在elasticsearch的这个JSON中?-LMLPHP

最佳答案

sort值根本不在您的文档中。实际上,只有在_source中看到的内容才是您的文档。
在另一个问题中,您可能未指定任何@timestamp字段而创建了索引模式,因此未在“发现” View 中对文档进行排序,并且您也未看到任何sort值。

09-20 11:02