python Fielddata is disabled on text fields

# 执行https://www.elastic.co/guide/cn/elasticsearch/guide/current/_aggregation_test_drive.html中的例子时报错Fielddata is disabled on text fields ,只需要在查询的fields后面加上.kewwords即可
# 参考https://blog.csdn.net/u011403655/article/details/71107415/
def curl_es(data):
    res = es.search(index="cars", doc_type="transactions", body=data)
    print(res)

body = {
    "size" : 0,
    "aggs" : {
        "popular_colors" : {
            "terms" : {
              "field" : "color.keyword"  #加上keyword就不报错了
            }
        }
    }
}
curl_es(body)

posted @ 2018-10-10 10:54  nanaindi  阅读(288)  评论(0编辑  收藏  举报