我一直在尝试使用" term"来搜索我的ES数据库。查询。我一直都是0次点击。
这是我的映射:
function initUserMapping() {
return elasticClient.indices.putMapping({
index: "user",
type: "document",
body: {
properties: {
fullName: { type: "string", index: "not_analyzed" },
email: { type: "string", index: "not_analyzed" },
password: { type: "string", index: "not_analyzed" },
movies: { type: "object" }
}
}
});
}
这就是我向" user"添加值的方法。 index(除电影外所有值都是字符串类型):
function addUser(User) {
console.log(User);
return elasticClient.index({
refresh: true,
index: "user",
type: "document",
body: {
properties: {
fullName: User.fullName,
email: User.email,
password: User.password,
movies: {}
}
}
});
}
这是我尝试查询db的众多排列之一:
function loginUser(User) {
console.log(User);
return elasticClient.search({
index: 'user',
body: {
query: {
term: {
email: User.email
}
}
}
});
}
这是我一直得到的回应:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}