如何使用mongo连接器与弹性搜索进行自定义映射 [英] How to do custom mapping using mongo connector with elasticsearch

查看:137
本文介绍了如何使用mongo连接器与弹性搜索进行自定义映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想连接 mongodb 弹性搜索。我使用 mongo连接器连接它们。我遵循下面的链接指令设置==>

I wanna connect mongodb and elasticsearch. I used mongo connector to connect them. I followed instruction from below link to setup==>

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

我可以连接mongodb和弹性搜索。但是默认情况下,mongo连接器为mongodb的所有数据库弹性搜索创建了索引。

I am able to connect mongodb and elasticsearch. But by default mongo connector created indices in elasticsearch for all databases of mongodb.

我想为我的一个数据库创建一个索引,而我只想插入所选的字段文档。例如:在mongo shell ==>

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==>

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.

以下是我尝试过的步骤,这不工作:
首先我开始mongo连接器,如下所示:

Below are the steps what I tried but thats not working : First I start mongo connector like below :

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.

然后从新的shell选项卡,我做了如下命令:

Then from new shell tab, I made command like :

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



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

但是,只有索引在弹性搜索中创建,名称为 hotels.restaurants 。我看不到任何索引 hotels.restaurants 的文件。

But only index is created in elasticsearch named as hotels.restaurants. I can't see any document for index hotels.restaurants.

请建议我如何为 hotels.restaurants 添加文档

Please suggest me how to add document for hotels.restaurants

推荐答案

我有一个答案我的问题,而启动mongo连接器,我们可以指定集合名称和我们感兴趣的字段列表请检查下面的命令==>

Well I got an answer to my question, while starting mongo connector we can specify collection name and the list of fields we are interested in. Please check below command ==>

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

这篇关于如何使用mongo连接器与弹性搜索进行自定义映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆