正如您在下面看到的 kibana 映射"type": "keyword",中已經提到的那樣,為什么它仍然給我一個錯誤,而我運行第二個代碼塊?
StatusCodeError: [illegal_argument_exception] 默認情況下,在文本欄位上禁用欄位資料。在 [time-stamp] 上設定 fielddata=true 以便通過反轉倒排索引將 fielddata 加載到記憶體中。請注意,這可能會占用大量記憶體。或者使用關鍵字欄位。<
{
"web": {
"aliases": {},
"mappings": {
"event": {
"properties": {
"participant-id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
}
}
},
我正在嘗試運行此代碼
else if(req.query["participant-id"] !== undefined)
{
console.log('participant id');
esClient.search({
index:ESindex,
body: {
sort:[{"time-stamp":{"order":"desc"}}],
size:req.query.count,
query: {
match_phrase: { "participant-id":req.query["participant-id"] },
}
}
},function (error, response,status) {
if (error){
console.log(error);
return res.json({ message: 'error' });
}
else {
response.hits.hits.forEach(function(hit){
return resData.push(hit);
})
}
return res.send(resData);
});
}
uj5u.com熱心網友回復:
您正在對time-stamp欄位進行排序,并且您共享的映射沒有 this field,我假設這被定義為text欄位,如果您的映射是動態生成的,您將擁有.keywordfor time-stamp,因此嘗試time-stamp.keyword在您的排序子句中使用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/463958.html
