因为有几天我遇到了无法解决的问题:
我想要发生的事情:我有一个集合,应该通过https://github.com/richardwilly98/elasticsearch-river-mongodb bevor转移到elasticsearch我创建河流我设置索引的自定义映射,这样我就不会得到动态映射,我可以在elasticsearch中使用geo_point类型 .
所以首先是Mongodb的蒙德尔:
screenName: { type: String, required: true, unique: true, sparse: true },
firstName: { type: String, validate: isString, index: true },
lastName: { type: String, validate: isString, index: true },
deleted: { type: Number, index: true, default: 0 },
homeBase: {
type: {
type: String,
default: 'Point'
},
coordinates: [Number] // [<longitude>, <latitude>]
},
realTime: {
type: {
type: String,
default: 'Point'
},
coordinates: [Number] // [<longitude>, <latitude>]
}
RealTime和homeBase是2dSpheres
预映射
{
"settings": {
"mapper": {
"dynamic": false
}
},
"mappings": {
"default": {
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"screenName": {
"type": "string"
},
"homeBase": {
"type": "object",
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
"realTime": {
"type": "object",
"properties": {
"coordinates": {
"type": "geo_point"
}
}
}
}
}
}
Wich也运行良好,并获得索引Url调用PUT localhost:9200 / users
现在是河
{
"type": "mongodb",
"mongodb": {
"servers": [
{
"host": "localhost",
"port": "27017"
}
],
"options": "drop_collection",
"db": "entities",
"collection": "users"
},
"index": {
"name": "users",
"type": "documents"
}
}
在这里我打电话给PUT http://localhost:9200/_river/users/_meta我收到的是{"error":"IndexAlreadyExistsException[[users] already exists]","status":400}
我需要什么?做像这样的查询
GET _search
{
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "mario",
"fields": ["firstName", "lastName", "specialities"]
}
},
"filter" : {
"mutate" {
"convert" => { "homeBase.coordinates" => "geo_point"}
},
"geo_bounding_box" : {
"homeBase.coordinates" : {
"top_left" : [1,100],
"bottom_right" : [1,100]
}
}
}
}
}
}
标准我如何得到位置字段是一个双,如果有人知道一种方法来查询双打坐标周围的位置它也没关系 .
请帮忙!
Mongodb:2.6.5 River 2.0.4 Elasticsearch:1.4.0
1 回答
我使用Put来创建River而不是Post,这导致出现奇怪错误的问题,即没有索引的文档 .
我把它改为POST一切都很好 .