我试图让 ElasticSearch 在我的 Mongodb 服务器上运行,一切看起来都很好,但我所做的每个查询都返回 0 次点击。总是。
我的安装和配置日志:
- 安装了MongoDB 2.6.4
启动并运行。这里没有问题。我在“产品”集合中有 7000 种产品。
.2 创建副本集。
用 Mongo shell 上的 rs.status() 确认它已创建并且它是主要副本 使用 resplSet = rs0 oplogSize=100 更改了 mongod.conf
.3. 重新启动 MongoDB
.4. 启动副本集
在 mongo shell rs.initiate() 上。一切都很好。
.5. 安装 ElasticSearch 1.3.2
{
"status": 200,
"name": "Franz Kafka",
"version": {
"number": "1.3.2",
"build_hash": "dee175dbe2f254f3f26992f5d7591939aaefd12f",
"build_timestamp": "2014-08-13T14:29:30Z",
"build_snapshot": false,
"lucene_version": "4.9"
},
"tagline": "You Know, for Search"
}
.6. 安装的映射器插件
.7. 安装的 River 插件
.8. 创建索引
curl -XPUT 'http://localhost:9200/indexprueba/products/_meta?pretty=true' -d '{
"type": "mongodb",
"mongodb": {
"db": "test",
"collection": "products"
},
"index": {
"name": "probando1",
"type": "products"
}
}'
它返回:
{
"_index": "indexprueba",
"_type": "products",
"_id": "_meta",
"_version": 1,
"created": true
}
- - - - 编辑 - - - - -
8.5 恢复数据库
我没有这样做。创建索引后,我使用 mongorestore 恢复我的数据库,这就是我得到的:
connected to: 127.0.0.1:27017
2014-09-08T08:17:17.773+0000 /var/backup/bikebud/products.bson
2014-09-08T08:17:17.773+0000 going into namespace [test.products]
Restoring to test.products without dropping. Restored data will be inserted without raising errors; check your server log
6947 objects found
2014-09-08T08:17:18.043+0000 Creating index: { key: { _id: 1 }, name: "_id_", ns: "test.products" }
2014-09-08T08:17:18.456+0000 /var/backup/bikebud/retailers.bson
2014-09-08T08:17:18.457+0000 going into namespace [test.retailers]
Restoring to test.retailers without dropping. Restored data will be inserted without raising errors; check your server log
20 objects found
2014-09-08T08:17:18.457+0000 Creating index: { key: { _id: 1 }, name: "_id_", ns: "test.retailers" }
所以我从这里了解到我的索引是创建并链接到数据库的
- - - - 编辑 - - - - -
.9. 创建简单查询
curl -XGET `'http://127.0.0.1:9200/indexprueba/_search?pretty=true&q=*:*'`
总是返回:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
- - - - - - - - 编辑 - - - - - - - - - -
编辑后,这是我得到的:
{
"took": 14,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "testindex1",
"_type": "products",
"_id": "1",
"_score": 1.0,
"_source": {
"type": "mongodb",
"mongodb": {
"servers": [
{
"host": "127.0.0.1",
"port": 27017
}
],
"options": {
"secondary_read_preference": true
},
"db": "test",
"collection": "products"
}
}
}
]
}
}
所以现在我得到了点击,但是索引本身。我期待从我的数据库中获取所有产品。我开始认为我根本不明白 elasticsearch 的作用。有什么线索吗??
- - - - - - - - 编辑 - - - - - - - - - -
我不知道我在这里错过了什么。请问,有什么建议吗?
- - - - - - - - 编辑 - - - - - - - - - -
看起来是版本问题。我必须将 ES 降级到 1.2.2(我使用的是 1.3.2)。“解决”