排序我有查詢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