排除Elastic缓存中的大量结果?

时间:2016-02-22 08:29:43

标签: elasticsearch

如何排除大量结果的查询?

我认为我无法使用:

"must_not" : { "multiples msg_id"

因为它可能是数千个被排除的项目。

在SQL中,查询将如下所示:

select m.* 
from messages as m 
left join msg_not_wanted as mnw 
on m.id=mnw.msg_id 
where user_id<>2;

CREATE TABLE messages (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
message VARCHAR(30) NOT NULL);

CREATE TABLE msg_not_wanted (
msg_id INT,
user_id INT);

insert into messages (message) values('a');
insert into messages (message) values('b');
insert into messages (message) values('c');
insert into messages (message) values('d');

insert into msg_not_wanted (msg_id,user_id) values(1,1);
insert into msg_not_wanted (msg_id,user_id) values(2,1);
insert into msg_not_wanted (msg_id,user_id) values(3,1);
insert into msg_not_wanted (msg_id,user_id) values(4,2);

0 个答案:

没有答案