排序我有查询POST查询现场坍塌的MAX_SCORE在elasticsearch
本地主机:8000/_search /漂亮=真& Q = Abbeline +黑色
{
"aggs": {
"dedup": {
"terms": {
"field": "image_url_hash",
"size":0
},
"aggs": {
"dedup_docs": {
"top_hits": {
"size": 1
}
}
}
}
}
}
响应:
{
"took": 84,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {...},
"aggregations": {
"dedup": {
"doc_count_error_upper_bound": 10,
"sum_other_doc_count": 2213,
"buckets": [
{
"key": "14fe6e82a38688aa13dd8592ab12e8c0",
"doc_count": 8,
"dedup_docs": {
"hits": {
"total": 8,
"max_score": 0.012580806,
"hits": [
{
"_index": "snder.co",
"_type": "product_feed",
"_id": "AVGucg-_uLMPZm4CUkuv",
"_score": 0.012580806,
"_source": {
"title": "Chinese Laundry Stilo Pointy Toe Pump Black 8.5",
"id": "17357703440022",
"image_url_hash": "14fe6e82a38688aa13dd8592ab12e8c0"
}
}
]
}
}
},
{
"key": "91fe5757349f5de7a5dcf716ebd6f3e3",
"doc_count": 7,
"dedup_docs": {
"hits": {
"total": 7,
"max_score": 0.012580806,
"hits": [
{
"_index": "snder.co",
"_type": "product_feed",
"_id": "AVGucjvluLMPZm4CUkyC",
"_score": 0.012580806,
"_source": {
"title": "Sorel Joan of Arctic Waterproof Boots Black 6",
"id": "17212803440017",
"image_url_hash": "91fe5757349f5de7a5dcf716ebd6f3e3",
}
}
]
}
}
},
{
"key": "81c48b614facf034653417498b8a1659",
"doc_count": 6,
"dedup_docs": {
"hits": {
"total": 6,
"max_score": 0.012577212,
"hits": [
{
"_index": "snder.co",
"_type": "product_feed",
"_id": "AVGucn3o7bmz9_YSCrEA",
"_score": 0.012577212,
"_source": {
"title": "Chinese Laundry Over The Knee Tie Back Boots Black 6",
"id": "17795103440017",
"image_url_hash": "81c48b614facf034653417498b8a1659",
}
}
]
}
}
},
{
"key": "d16c929f3490620e95ad0ef8e8d3117a",
"doc_count": 6,
"dedup_docs": {
"hits": {
"total": 6,
"max_score": 0.018849576,
"hits": [
{
"_index": "snder.co",
"_type": "product_feed",
"_id": "AVGucedY7bmz9_YSCq4l",
"_score": 0.018849576,
"_source": {
"title": "Abbeline Tank Black S",
"id": "17480407090041",
"image_url_hash": "d16c929f3490620e95ad0ef8e8d3117a",
}
}
]
}
}
}
]
}
}
}
现在它按doc_count的数量排序。我想通过_score对桶进行分类。
我改变了这种要求为localhost:8000/_search /漂亮=真& Q = Abbeline +黑色
{
"aggs": {
"dedup": {
"terms": {
"field": "image_url_hash",
"order": {
"top_hit": "desc"
}
},
"aggs": {
"dedup_docs": {
"top_hits": {}
},
"top_hit" : {
"max": {
"script": "_score"
}
}
}
}
}
}
而且我不断收到此错误
{ “错误”:“ SearchPhaseExecutionException [无法执行阶段 [查询],所有分片失败; shardFailures {[OiTaTwM1S_CyfvTX1bDNrg] [snder.co] [0]: RemoteTransportException [[Burstarr] [inet [/ xxxx:y]] [indices:data /读/搜索[相位/查询]]]; 嵌套:SearchParseException [[snder.co] [0]: from [-1],size [-1]:Parse Failure [解析失败[{\ n \“aggs \”:{\ n \ “\ n \”terms \“:{\ n \”field \“: \”image_url_hash \“,\ n \”order \“:{\ n \”top_hit \“: \”desc \ n \ n \ n \ n \ n \ n,\ n \“aggs \”:\ n
\“dedup_docs \”:{\ n \“top_hits \”:{} \ n},\ n
\“top_hit \“:{\ n \”max \“:{\ n \”script \“: \”_ score \“\ n} \ n} \ n \ n} \ n} \ n } \ n}]] ]。嵌套:ScriptException [动态脚本为[groovy] 禁用]; RemoteTransportException [[Burstarr] [inet [/x.x.x.xyy]] [indices:data/read/search [phase/query]]];} {[OiTaTwM1S_CyfvTX1bDNrg] [snder.co] [1]: 嵌套:SearchParseException [[snder.co] [1]: from [-1],size [-1]:解析失败[解析失败[{\ n \“aggs \”:{\ n \ “\ n \”terms \“:{\ n \”field \“: \”image_url_hash \“,\ n \”order \“:{\ n \”top_hit \“: \”desc \ n \ n \ n \ n \ n \ n,\ n \“aggs \”:\ n
\“dedup_docs \”:{\ n \“top_hits \”:{} \ n},\ n
\“top_hit \“:{\ n \”max \“:{\ n \”script \“: \”_ score \“\ n} \ n} \ n \ n} \ n} \ n } \ n}]] ]。嵌套:ScriptException [动态脚本为[groovy] 禁用]; RemoteTransportException [[Burstarr] [inet [/x.x.x.xyy]] [indices:data/read/search [phase/query]]];} {[OiTaTwM1S_CyfvTX1bDNrg] [southmoonunder.com] [2]: 嵌套:SearchParseException [[snder.co] [2]: from [-1],size [-1]:解析失败[解析源失败[{\ n \“aggs \”:{\ n \ “\ n \”terms \“:{\ n \”field \“: \”image_url_hash \“,\ n \”order \“:{\ n \”top_hit \“: \”desc \ n \ n \ n \ n \ n \ n,\ n \“aggs \”:\ n
\“dedup_docs \”:{\ n \“top_hits \”:{} \ n},\ n
\“top_hit \“:{\ n \”max \“:{\ n \”script \“: \”_ score \“\ n} \ n} \ n \ n} \ n} \ n } \ n}]] ]。嵌套:ScriptException [动态脚本为[groovy] 禁用]; } {[OiTaTwM1S_CyfvTX1bDNrg] [southmoonunder.com] [3]: RemoteTransportException [[Burstarr] [inet [/x.x.x。X:Y]] [指数:数据/读取/搜索[相位/查询]]]; 嵌套:SearchParseException [[snder.co] [3]: from [-1],size [-1]:解析失败[解析失败[{\ n \“aggs \”:{\ n \ “\ n \”terms \“:{\ n \”field \“: \”image_url_hash \“,\ n \”order \“:{\ n \”top_hit \“: \”desc \ n \ n \ n \ n \ n \ n,\ n \“aggs \”:\ n
\“dedup_docs \”:{\ n \“top_hits \”:{} \ n},\ n
\“top_hit \“:{\ n \”max \“:{\ n \”script \“: \”_ score \“\ n} \ n} \ n \ n} \ n} \ n } \ n}]] ]。嵌套:ScriptException [动态脚本为[groovy] 禁用]; RemoteTransportException [[Burstarr] [inet [/x.x.x.xyy]] [indices:data/read/search [phase/query]]];} {[OiTaTwM1S_CyfvTX1bDNrg] [southmoonunder.com] [4]: 嵌套:SearchParseException [[snder.co] [4]: from [-1],size [-1]:Parse Failure [解析失败[{\ n \“aggs \”:{\ n \ “\ n \”terms \“:{\ n \”field \“: \”image_url_hash \“,\ n \”order \“:{\ n \”top_hit \“: \”desc \ n \ n \ n \ n \ n \ n,\ n \“aggs \”:\ n
\“dedup_docs \”:{\ n \“top_hits \”:{} \ n},\ n
\“top_hit \“:{\ n \”max \“:{\ n \”script \“: \”_ score \“\ n} \ n} \ n \ n} \ n} \ n } \ n}]] ]。嵌套:ScriptException [动态脚本为[groovy] 禁用]; }]”,‘状态’:400}
能有人帮我我怎么排序MAX_SCORE代替doc_counts
谢谢这么多,我使用亚马逊弹性搜索,不幸的是它不支持动态脚本。我现在已经安装了elasticsearch和新服务器可以提出上述要求。谢谢。 – Pooja
不错,谢谢你的更新。 – Val