我正在嘗試進行查詢以獲取 Elastic 中兩個不同索引的資訊:
GET _search
{
"query": {
"bool": {
"must" : [{
"bool" : {
"should" : [{
"match" : {
"action": "VoiceQueueAbandonAction"
}},
{
"match" : {
"action": "QualifyVoiceWel"
}
}
]
}
}
],
"filter": {
"range": {
"created_at": {
"gte": "2022-05-04 00:00:00",
"lte": "2022-05-04 23:59:59"
}
}
}
}
}
}
它來對了,但它是重復資訊,因為在索引“qualifications”和“queueevents”中有相同的動作“QualifyVoiceWel”。
在這種情況下,我需要過濾“QualifyVoiceWel”欄位僅來自資格索引,而不是來自 queueevents!
uj5u.com熱心網友回復:
您可以在現有的內部添加bool子句,should如下所示:
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"match": {
"action": "VoiceQueueAbandonAction"
}
},
{
"bool": {
"must": [
{
"match": {
"action": "QualifyVoiceWel"
}
},
{
"term": {
"_index": {
"value": "qualifications"
}
}
}
]
}
}
]
}
}
],
"filter": {
"range": {
"created_at": {
"gte": "2022-05-04 00:00:00",
"lte": "2022-05-04 23:59:59"
}
}
}
}
}
}
uj5u.com熱心網友回復:
根據您的要求提供兩種選擇:
- 通過 /<index_name>/_search 查詢正確的索引
或者
- 索引名稱可在查詢中用作
_index. 本檔案提供了更多詳細資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/473327.html
上一篇:使用Typescript以及使用node和Express滾動的索引彈性問題
下一篇:將陣列中的兩個重復值轉換為字串
