【发布时间】:2016-09-19 18:03:09
【问题描述】:
ES JS 客户端发生了一些非常奇怪的事情。 client.search() 方法似乎工作正常,索引和搜索数据工作正常,但如果重新启动 elasticsearch.bat 则客户端停止工作。我的意思是,client.search 用相同的代码给了我 0 次点击。但是,如果我使用任何其他客户端进行搜索,我会在索引中找到所有可用的文档。
这是使用此 GET http://localhost:9200/yojuego/_mappings 的映射:
{
"yojuego": {
"mappings": {
"user": {
"properties": {
"password": {
"type": "string"
}
"type": {
"type": "string"
}
"userid": {
"type": "string"
}
}
}
}
}
}
这是我从 NodeJS 中查找信息的方式:
this.client.search({
index: "yojuego",
type: "user",
body: {
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{ "term": { "userid": criteria } },
{ "term": { "type": "yojuego" } }
]
}
}
}
}
}
}, (error, response, status) => {
if (error) {
//I have no error
}
else {
//Here is where I have 0 hits in response.hits.hits
}
});
相关帖子:
- ElasticSearch Indexing and Searching Not Working Correctly
- ElasticSearch JS Client Search by
- ElasticSearch JS query returns all document instead of filtered
我收到了很多答案,一开始都可以正常工作,但后来都停止工作了
我正在使用的框架:
- 弹性搜索 2.4.0
- Node.js 6.3.0
- ElasticSearch.js 11.0.1
我是如何安装 ElasticSearch 的? 只需从 ES 网站下载,解压并运行 elasticsearch.bat(我在 Windows 7 上运行)
同样,问题是在 ES 服务重置后 ES 停止工作。 当然,我很确定我做错了什么,但我无法意识到 ES Service Search 突然停止工作的位置和原因。
当我说“停止工作”时,我是说来自 ES js 客户端的搜索方法检索 0 与昨天使用的相同查询匹配。
我希望我解释清楚了。 谢谢。
警察局:
这是我初始化 es 客户端的方式:
var es = require('elasticsearch');
var client = new es.Client({
host: 'http://localhost:9200',
log: 'info'
});
【问题讨论】:
-
您能否编辑您的问题以包括您如何在 JS 代码中设置和初始化连接?
-
完成!!!谢谢。
-
在客户端初始化中添加
keepAlive: false会发生什么? -
什么都没有改变
-
你能检查一下elasticsearch日志吗?解压后的ES文件夹下应该有一个“log”文件夹。您还可以使用 Wireshark 查看客户端发送的确切请求以及 ES 返回的响应。那里可能有一些线索......
标签: javascript node.js search elasticsearch elasticsearch.js