【发布时间】:2015-02-04 19:30:49
【问题描述】:
我在 MongoDB 中使用 ElasticSearch,并希望在我的 Elasticsearch 索引中搜索 ObjectID。
我的 MongoDB 包含以下条目:
{ "_id" : ObjectId("54ca06664ceb6693d37de155"), "blabla" : "xxxyyy"}
我尝试创建自定义映射,例如:
curl -XPOST "http://localhost:9200/myIndex/myType/_mapping" -d'
{
"myType":{
"properties":{
"_all": {
"enabled": false
},
"_id": {
"type": "string",
"store": true,
"index": "analyzed"
},
"blabla": {
"type": "string",
"store": true,
"index": "analyzed"
}
}
}'
但是当我想用
检查我的映射时curl -XGET 'http://localhost:9200/_all/_mapping'
我看不到 _id 映射。搜索“54ca06664ceb6693d37de155”也不会返回任何结果。
怎么了?
【问题讨论】:
-
如何将数据从 MongoDB 加载到 Elasticsearch?您是否在加载任何数据之前创建了此映射?
-
我正在使用 River (github.com/richardwilly98/elasticsearch-river-mongodb)。首先创建索引,然后创建映射,最后创建河流。它适用于其他字段,但不幸的是不适用于“id”字段。
标签: mongodb elasticsearch