Elasticsearch按嵌套计数

时间:2018-04-11 14:38:29

标签: elasticsearch

我有一个带链接的产品,已映射

{
  "mappings": {
    "product": {
      "properties": {
        "links": {
          "type": "nested"
        }
      }
    }
  }
}

如何对链接的长度进行排序?我尝试了以下但是不起作用:

{
  "sort": {
    "_script": {
      "script": "doc['links'].values.length",
      "order": "desc",
      "type": "string"
    }
  }
}

我得到的错误是:["org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:81)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)","doc['links'].values.length"," ^---- HERE"],"script":"doc['links'].values.length","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"No field found for [links] in mapping with types []"}}}]},"status":500}

0 个答案:

没有答案