简体   繁体   English

如何使用Mongo Connector和Elasticsearch进行自定义映射

[英]How to do custom mapping using mongo connector with elasticsearch

I wanna connect mongodb and elasticsearch . 我想连接mongodbelasticsearch I used mongo connector to connect them. 我用mongo连接器连接它们。 I followed instruction from below link to setup==> 我按照下面的说明从链接到setup ==>

http://vi3k6i5.blogspot.in/2014/12/using-elastic-search-with-mongodb.html http://vi3k6i5.blogspot.in/2014/12/using-elastic-search-with-mongodb.html

I am able to connect mongodb and elasticsearch. 我能够连接mongodb和elasticsearch。 But by default mongo connector created indices in elasticsearch for all databases of mongodb. 但是默认情况下,mongo连接器在elasticsearch中为mongodb的所有数据库创建了索引。

I want to create only one index for my one database and I want to insert only selected field of documents. 我只想为我的一个数据库创建一个索引,并且只想插入文档的选定字段。 for example: in mongo shell==> 例如:在mongo shell ==>

use hotels
db.restaurants.insert(
   {
      "address" : {
     "street" : "2 Avenue",
     "zipcode" : "10075",
     "building" : "1480",
     "coord" : [ -73.9557413, 40.7720266 ],
  },
  "borough" : "Manhattan",
  "cuisine" : "Italian",
  "grades" : [
     {
        "date" : ISODate("2014-10-01T00:00:00Z"),
        "grade" : "A",
        "score" : 11
     },
     {
        "date" : ISODate("2014-01-16T00:00:00Z"),
        "grade" : "B",
        "score" : 17
     }
  ],
  "name" : "Vella",
  "restaurant_id" : "41704620"
  }
)

This will create database hotels and collection restaurants . 这将创建数据库酒店收藏餐厅 Now I want to create index and I want to put only address field in elasticsearch for that index. 现在,我想创建索引,并且只想在该索引的弹性搜索中放入地址字段

Below are the steps what I tried but thats not working : First I start mongo connector like below : 下面是我尝试的步骤,但是那是行不通的:首先,我启动mongo连接器,如下所示:

Imomadmins-MacBook-Pro:~ jayant$ mongo-connector -m localhost:27017 -t       localhost:9200 -d elastic_doc_manager --oplog-ts oplogstatus.txt

Logging to mongo-connector.log.

Then from new shell tab, I made command like : 然后从新的shell选项卡中,我发出如下命令:

curl -XPUT 'http://localhost:9200/hotels.restaurants/'



curl -XPUT "http://localhost:9200/hotels.restaurants/string/_mapping" -    d'{
    "string": {
        "properties" : {
        "address" : {"type" : "string"}
         }
     }
 }'

But only index is created in elasticsearch named as hotels.restaurants . 但是在弹性搜索中仅创建名为Hotels.restaurants的索引 I can't see any document for index hotels.restaurants . 我找不到索引hotel.restaurants的任何文档。

Please suggest me how to add document for hotels.restaurants 请建议我如何为hotel.restaurants添加文件

好了,我得到了我的问题的答案,在启动mongo连接器时,我们可以指定集合名称和我们感兴趣的字段列表。请检查以下命令==>

$ mongo-connector -m localhost:27017  -t localhost:9200 -d elastic_doc_manager --oplog-ts oplogstatus.txt --namespace-set hotels.restaurants --fields address,grades,name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用mongo-connector的风帆电梯失去了Elasticsearch Mapping - Elasticsearch Mapping lost on sails lift with mongo-connector 如何使用mongo-connector仅对特定mongodb数据库中的特定集合进行索引(elasticsearch)。 - how to index (elasticsearch) only specific collection in a specific mongodb database using mongo-connector. elasticsearch mongo-connector卡在“登录到mongo-connector.log”中 - elasticsearch mongo-connector stuck in “Logging to mongo-connector.log” 如何使用 spark mongo 连接器在 mongo 查询管道中使用聚合 - How to use aggregate in the mongo query pipeline using spark mongo connector 部分单词搜索在使用 mongo-connector 的 elasticsearch (elasticsearch-py) 中不起作用 - Partial word search not working in elasticsearch (elasticsearch-py) using mongo-connector 使用 mongo-kafka 作为接收器连接器,如何将字段的值设置为 Date 类型? - Using mongo-kafka as sink connector, how do I set a field's value to be of Date type? 使用mongo-connector过滤文档到elasticsearch - Filter documents with mongo-connector to elasticsearch 使用mongo-connector连接mongodb和elasticsearch - Connecting mongodb and elasticsearch with mongo-connector Mongo-Connector 不向 Elasticsearch 发送数据 - Mongo-Connector not sending data to Elasticsearch Elasticsearch mongo-connector KeyError _id - Elasticsearch mongo-connector KeyError _id
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM