mongodb - 将数据MongoDB导出到ElasticSearch

标签 mongodb elasticsearch

我想将数据从MongoDB导出到ElasticSearch.Mongo River插件是我首先采取收集转储然后恢复的选项,这对我来说很好用。但是我不想使用Mongo River插件,我使用elaster进行导出数据从MongoDB到Elasticsearch。

  • flex 搜索版本-1.3.2
  • Node.js版本-v0.11.8-pre
  • MongoDB版本-2.4.x

  • 当我执行:./bin/elaster时,它说:
    { 
      [Error: MapperParsingException[object mapping for [collection] tried to parse as object, but got EOF, has a concrete value been provided to it?]]
      message: 'MapperParsingException[object mapping for [collection] tried to parse as object, but got EOF, has a concrete value been provided to it?]'
    }
    

    我的Elaster配置为:
    module.exports = {
    
      mongo: {
        connection: 'mongodb://127.0.0.1:27017/times'
      },
    
      elastic: {
        host: {
          host: '127.0.0.1'
        },
        requestTimeout: 5000
      },
    
      collections: [ 
        {
          name: "walldisplay",
          index: "walldisplay",
          type: "collection",
          fields: [
            "_id",
            "wat",
            "wct",
            "u",
            "i",
            "cd"
          ],
          mappings: {
            "collection": {
              "properties": {
                "wat":{
                  'type':'string',
                  'index': 'not_analyzed'
                },
                "wct":{
                  'type':'string',
                  'index': 'not_analyzed'
                },
                "u":{
                  "type" : "object",
                  "dynamic" : true,
                  "properties":{
                    "_id":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "n":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "st":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "id":{
                      'type':'string',
                      'index': 'not_analyzed'
                    }
                  },
                  "index":"not_analyzed"
                },
                "i":{
                  "type" : "nested",
                  "include_in_parent" : true,
                  "properties":{
                    "_id":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "ti":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "st":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "n":{
                      'type':'string',
                      'index': 'not_analyzed'
                    },
                    "cst":{
                      'type':'string',
                      'index': 'not_analyzed'
                    }
                  }
                },
                "cd":{
                  'type':'long',
                  'index': 'not_analyzed'
                },
              }
            }
          }
        }
      ]
    };
    

    也请在线检查样本文件
    {
      "_id": ObjectId("5406a47970b17246b9a293e1"),
      "cd": 1409721465,
      "i": [
        {
          "_id": ObjectId("50f693d17deed44cf000007f"),
          "st": "seo-title",
          "ti": "title",
          "n": "categoryname",
          "cst": "category-seotitle",
          "r": null,
          "c": null
        },
        {
          "_id": ObjectId("50f693d17deed44cf000007f"),
          "st": "seo-title",
          "ti": "title",
          "n": "categoryname",
          "cst": "category-seotitle",
          "r": null,
          "c": null
        },
        {
          "_id": ObjectId("50f693d17deed44cf000007f"),
          "st": "seo-title",
          "ti": "title",
          "n": "categoryname",
          "cst": "category-seotitle",
          "r": null,
          "c": null
        }
      ],
      "u": {
        "_id": ObjectId("50ce4f79edaffd69e40ee010"),
        "n": "Richa Sen",
        "st": "richasen",
        "id": "d8mzxlp9ekn323l6jg5s8tly1"
      },
      "wat": 1,
      "wct": 1
    }
    

    最佳答案

    由于已将“collection”定义为类型,将索引定义为“walldisplay”,因此映射中的类型应为“collection”而不是“walldisplay”。

    The put mapping API allows to register specific mapping definition for a specific type



    看看下面的作品
     ..
         mappings:{
                    "collection":{
                           "properties":{
                                  ...
                               }
                         }
                   }
    

    关于mongodb - 将数据MongoDB导出到ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25642731/

    相关文章:

    mongodb - 无法在 Docker 上使用 Rocketchat 连接到本地主机

    java - Morphia List<Map<String,Object>>> 在查找操作中返回嵌入式元素不是 DBObject

    javascript - 在 mongo shell 中使用 printjson 进行 mongoDB 调试

    java - Java中的Mongo ISODate查询

    node.js - Mongoose :如何防止mongodb在数据库中保存重复的电子邮件记录

    python - 使用elasticsearch遍历查询的所有结果

    elasticsearch - 为什么在 Elasticsearch 中创建150个滚动上下文?

    elasticsearch - @在 Elasticsearch 文档中是什么意思?

    elasticsearch - 大量删除的文档会影响查询速度吗?

    Crud 存储库的 Spring bean 配置