我需要帮助来构建弹性查询,跳过channelMessage.channelMessageType
等于RESUME_EXECUTION
且replyMessages
数组为空或第一个元素channelMessageType
等于INTENT_FINISHED
的记录。
在夏天像:
(channelMessage.channelMessageType equal 'RESUME_EXECUTION' AND (replyMessages is empty or first element .'channelMessageType' equal 'INTENT_FINISHED'))
查询字段Map信息:
"channelMessage": {
"dynamic": "true",
"properties": {
"channelMessageType": {
"type": "text",
"store": true,
"fielddata": true
},...
"replyMessages": {
"type": "nested",
"dynamic": "true",
"properties": {
"channelMessageType": {
"type": "text",
"store": true,
"fielddata": true
},...
到目前为止,我尝试了:
{
"bool" : {
"must_not" : [
{
"bool" : {
"must" : [
{
"term" : {
"channelMessage.channelMessageType" : {
"value" : "RESUME_EXECUTION",
"boost" : 1.0
}
}
}
],
"must_not" : [
{
"exists" : {
"field" : "replyMessages.channelMessageType",
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must" : [
{
"term" : {
"channelMessage.channelMessageType" : {
"value" : "RESUME_EXECUTION",
"boost" : 1.0
}
}
},
{
"script" : {
"script" : {
"source" : "doc['replyMessages.channelMessageType'].length == 1",
"lang" : "painless"
},
"boost" : 1.0
}
},
{
"term" : {
"replyMessages.channelMessageType" : {
"value" : "INTENT_FINISHED",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
任何帮助都将不胜感激!
1条答案
按热度按时间bmvo0sr51#
在阅读更多的弹性文档时,我发现了以下warning:
通过检查索引Map类型,
channelMessage.channelMessageType
是text
,这是查询不起作用的原因。通过将所有term
替换为match
运算符,我的问题解决了!