[英]ElasticSearch JS query returns all document instead of filtered
i am with this problem: ElasticSearch JS returns all documents when I try to filter them. 我遇到这个问题:当我尝试过滤它们时,ElasticSearch JS返回所有文档。 I have two documents, only one that match with those filters, however ES returns all documents... There is no mappings created, only two documents created.
我有两个文档,只有一个与那些过滤器匹配,但是ES返回所有文档...没有创建映射,仅创建了两个文档。 I dont know what to do...
我不知道该怎么办...
I'm using Node JS 我正在使用Node JS
client.search({
index: "yojuego",
type: "user",
query: {
"filtered": {
"filter": {
"bool": {
"must": [
{ "term": { "userid": "123456789" } },
{ "term": { "type": "yojuego" } }
]
}
}
}
}
}, (error, response, status) => {
if (error) {
res.json(400, err);
}
else {
res.json(200, response.hits.hits);
}
});
});
You have a typo in your search parameters, you need to enclose your query
into the body
parameter. 您的搜索参数中有一个错字,您需要将
query
包含在body
参数中。
client.search({
index: "yojuego",
type: "user",
body: { <--- add this
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{ "term": { "userid": "123456789" } },
{ "term": { "type": "yojuego" } }
]
}
}
}
}
}
}, (error, response, status) => {
if (error) {
res.json(400, err);
}
else {
res.json(200, response.hits.hits);
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.