我有一个mysql查询。我如何在elasticsearch中建模此查询?
查询是 -
select targetId from mytable where actorId=? and targetId in (select actorId from mytable where targetId = ?)
{
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"bool" : {
"must" : [ {
"term" : {
"actorId" : 3432079
}
},
{
"not" : {
"filter" : {
"terms" : {
"targetId" : [3435089, 3435093]
}
}
}
}]
}
}
}
}
编辑:
而不是上面我想做如下
{
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"bool" : {
"must" : [ {
"term" : {
"actorId" : 3432079
}
},
{
"not" : {
"filter" : {
"terms" : {
"targetId" : (inner query which returns target ids)
}
}
}
}]
}
}
}
}