【发布时间】:2018-07-02 07:26:34
【问题描述】:
这是我的映射的 sn-p:
"products": {
"properties": {
"availability_date": {
"type": "date"
},
"banner": {
"properties": {
"id": {
"type": "long"
},
"copyright": {
"type": "keyword"
},
"url": {
"type": "keyword"
}
}
},
"categories": {
"type": "nested",
"properties": {
"id": {
"type": "long"
},
"category_type": {
"type": "keyword"
},
"name": {
"type": "text"
}
}
}
}
我想根据“categories.name”对搜索结果进行排序
我试着用:
"sort":[
{
"categories.name":{
"order":"asc",
"nested_path":"categories"
}
}
],
但这不起作用并返回一条消息:
“默认情况下,在文本字段上禁用字段数据。在 [categories.name] 上设置 fielddata=true 以便通过反转倒排索引将字段数据加载到内存中。请注意,这可能会占用大量内存。或者使用关键字字段而是。”
然后我将映射更改为:
"products": {
"properties": {
"availability_date": {
"type": "date"
},
"banner": {
"properties": {
"id": {
"type": "long"
},
"copyright": {
"type": "keyword"
},
"url": {
"type": "keyword"
}
}
},
"categories": {
"type": "nested",
"properties": {
"id": {
"type": "long"
},
"category_type": {
"type": "keyword"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "sort_normalizer"
}
}
}
}
}
}
我现在如何进行排序?我试过这个:
"sort":[
{
"categories.name.keyword":{
"order":"asc",
"nested_path":"categories.name"
}
}
],
这不合理:
“[nested] 未能在路径 [categories.name] 下找到嵌套对象”
其他一些地图工作,但给我未排序的结果
【问题讨论】:
-
你最后找到解决办法了吗?我也面临着类似的问题
标签: sorting elasticsearch nested