1
我想按列表長度對搜索進行排序。我有一個字段由Elasticsearch如何按列表長度排序
"authors": {
"type": "text", "norms": { "enabled": False }, "analyzer": "autocomplete_with_asciifolding", "search_analyzer": "with_and_without_accent_search", "position_increment_gap": 100,
"fields": {
"raw" : { # This field is needed for your_paper suggestions search
"type" : "string",
"analyzer" : 'lower_keyword'
}
}
}
定義現在我想通過這個領域,這可能看起來像排序[「李四」,'邁克史密斯]
繼elasticsearch文檔和一些谷歌搜索我發現
doc['sort'] = {
"_script": {
"type": "number",
"script": "doc['authors'].length",
"order": "asc"
}
}
我也試過DOC [ '作家'。values.length()和DOC [ '作家'。values.size(),但他們都導致
TransportError: TransportError(500, u'search_phase_execution_exception')
任何想法如何按列表的長度進行排序?