【问题标题】:Elasticsearch Mapping lost on sails lift with mongo-connectorElasticsearch Mapping 在使用 mongo-connector 的帆升降机上丢失
【发布时间】:2015-05-25 12:12:15
【问题描述】:

我正在使用 MongoDB、Sails JS 和 ElasticSearch 开发应用程序。

MongoDB 用于编写为应用程序检索的记录。 ElasticSearch用于搜索文本和地理位置距离搜索等。

我正在使用 mongo-connector 将我的数据从 MongoDB 同步到 ElasticSearch。

问题是,我无法为存储 lat 和 lon 或父/子或分析器等的字段维护 geo_point 的映射。每次提升sails 服务器时,我都会在 elasticsearch 日志中看到所有映射都已删除,创建和更新,并且我丢失了我的 geo_point 映射,该映射是在每件事都启动并运行之后通过 REST 手动创建的,或者即使我在sails js 的引导时创建了映射(作为一种解决方法)。

我也尝试创建一个映射文件并将其放在 elasticsearch/config/mappings/index/mymapping.json 中,但出现错误

Caused by: org.elasticsearch.index.mapper.MapperParsingException: Root type mapping not empty after parsing! Remaining fields: ...

在这里我尝试了所有的组合来完成这项工作,但没有成功,例如

{"mappings" : {
        "locations" : {
            "dynamic": "false",
            "properties":{
                "location": {
                    "type": "geo_point"
                }
            }
        }
    }
}

还尝试使用模板创建映射,但之后 mongo-connector 启动并覆盖了映射。

到目前为止,我只能停止 mongo-connector,删除 oplog.timestamp 文件,启动sails 服务器(在引导时我删除并重新创建该文档的映射)然后启动mongo 连接器。但是如果我们忘记了一步,这就会造成事故。

我做错了什么还是有更好的方法将 mongodb 同步到 elasticsearch 而不会丢失自定义映射或替代 mongo-connector。

【问题讨论】:

    标签: node.js mongodb elasticsearch sails.js


    【解决方案1】:

    根据documentation,如果您在文件系统上安装映射,则该文件必须命名为<your_mapping>.json,因此在您的情况下,它应该命名为locations.json 并放置在

    elasticsearch/config/mappings/_default/locations.json
    

    elasticsearch/config/mappings/<your_index_name>/locations.json
    

    此外,您的映射文件不应包含 mappings 关键字,而应如下所示:

        {
            "locations" : {
                "dynamic": "false",
                "properties":{
                    "location": {
                        "type": "geo_point"
                    }
                }
            }
        }
    

    您应该在正确命名映射文件和文件夹后重试。

    【讨论】:

      猜你喜欢
      • 2014-10-16
      • 1970-01-01
      • 1970-01-01
      • 2016-02-19
      • 2015-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多