我有以下查詢:
router.get('/date', (req, res)=>{
let query = {
index: 'decisions',
size: 5000,
from: 0,
body:{
query:{
filtered:{
filter:{
bool:{
must:[{
"range": {
"Date_Lecture": {
"gt": "2019-04-04",
"lt": "2019-04-06"
}
}
}]
}
}
}
}
},
}
if(req.query.decisions) query.q = `*${req.query.decisions}`
client.search(query)
.then(resp=>{
return res.status(200).json({
decisions: resp.hits
})
.catch(err=>{
console.log(500).json({
msg:'Error',
err
})
})
})})
我想從彈性中獲取這些日期范圍內的記錄,但它給了我這個錯誤,并說它不知道過濾器,如果我洗掉過濾器,然后它說它不知道過濾器,如果我只是使用range 然后它也說它不知道 range 關鍵字。
root_cause: [
{
type: 'parsing_exception',
reason: 'unknown query [filtered]',
line: 1,
col: 22
}
],
uj5u.com熱心網友回復:
該filtered查詢早已逝去(因為ES 5.0),你應該改變你的查詢到這一點:
body:{
query:{
bool:{
filter:[{
"range": {
"Date_Lecture": {
"gt": "2019-04-04",
"lt": "2019-04-06"
}
}
}]
}
}
},
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/392297.html
