具有自定义映射的Elasticsearch Bridge和MongoDB IndexAlreadyExist

时间:2015-08-10 16:30:08

标签: mongodb elasticsearch elasticsearch-river

因为有几天我遇到了无法解决的问题:

我想要发生什么: 我有一个应该通过https://github.com/richardwilly98/elasticsearch-river-mongodb转移到elasticsearch的集合 bevor我创建了河流,我设置了索引的自定义映射,这样我就不会得到动态映射,我可以在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"
                    }
                }
            }
        }
    }
}

它也可以很好地工作并获得索引 网址呼叫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 我收到的是 { &#34;错误&#34; :&#34; IndexAlreadyExistsException [[users]已经存在]&#34;, &#34;状态&#34; :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 河2.0.4 Elasticsearch:1.4.0

1 个答案:

答案 0 :(得分:0)

我使用Put来创建River而不是Post,这导致了出现奇怪错误的问题,即没有索引的文档。

我把它改成POST一切都很好。