1

我一直在尝试使用“术语”查询来搜索我的 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" }
            }
        }
    }); 
}

这就是我向“用户”索引添加值的方式(所有值都是字符串类型,除了电影):

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: {}
        }
    }
});
}

这是我尝试查询数据库的众多排列之一:

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": []
}
}
4

0 回答 0