我有一個文件如何在elasticsearch上的特定字段上使用排序我的查詢如下{ "sort":{ "name":"desc" }, "from":10, "size":149, "query":{ "match_all":{ } }}我收到錯誤Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [name] in order to load field data by uninverting the inverted index. Note that this can use significant memory.')\"}" }我的索引名稱是 data_new下面是插入索引的代碼test = [ {'id':1,'name': 'Cost Accounting 400', 'professor': ['Bill Cage', 'accounting']}, { 'id':2, 'name': 'Computer Internals 250', 'professor': ['Gregg Payne', 'engineering']}, {'id':3, 'name': 'Accounting Info Systems 350', 'professor': ['Bill Cage', 'accounting']}, {'id':4,'name': 'Tax Accounting 200', 'professor': ['Thomas Baszo', 'finance']}, {'id':5,'name': 'Capital Markets 350', 'professor': ['Thomas Baszo', 'finance']}, {'id':6,'name': 'Theatre 410', 'professor': ['Sebastian Hern', 'art']}, {'id':7,'name': 'Accounting 101', 'professor': ['Thomas Baszo', 'finance']}, {'id':8,'name': 'Marketing 101', 'professor': ['William Smith', 'finance']}, {'id':8,'name': 'Anthropology 230', 'professor': ['Devin Cranford', 'history']}, {'id':10, 'name': 'Computer Science 101', 'professor': ['Gregg Payne', 'engineering']}]from elasticsearch import Elasticsearchimport jsones = Elasticsearch()es.indices.create(index='data_new', ignore=400)for e in test: es.index(index="data_new", body=e, id=e['id'])search = es.search(index="data_new", body={"from" : 0, "size" : 2,"query": {"match_all": {}}})search['hits']['hits']預計出我的第一個預期輸出>我需要對輸出進行name排序第二個預期輸出 > 相對于namethen排序id如何進行修改search = es.search(index="data_new", body={"from" : 0, "size" : 2,"query": {"match_all": {}}})https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-sort.html我瀏覽了沒有幫助的網址
查看完整描述