【问题标题】:Integrate MONGODB and SOLR集成 MONGODB 和 SOLR
【发布时间】:2017-12-28 21:00:49
【问题描述】:

我尝试使用 mongodb 提供的 MONGO CONNECTOR 集成 MONGODB 和 SOLR,该连接器在副本集配置中运行。

**python2.7 mongo_connector.py -m localhost:27017 -t http://localhost:8983/solr -u_id -d ./doc_managers/solr_doc_manager.py**

我的输出是

2013-06-19 16:19:10,943 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (post) with body 'u'<commit ' in 0.012 seconds.

但我无法配置 SOLR 以从 MONGODB 获取文档。请帮助我如何配置 SOLR 以从 MONGODB 获取文档。我应该使用 SolrMongoImporter 吗?

【问题讨论】:

    标签: mongodb solr


    【解决方案1】:

    我也遇到了同样的问题。我无法解决,所以我找到了一个有趣的链接: http://derickrethans.nl/mongodb-and-solr.html 它通过 php 脚本将 mongo 与 solr 连接起来。一个

    【讨论】:

      【解决方案2】:

      第 1 步:安装 Mongo 连接器

      安装 mongo 连接器运行

       Pip install mongo-connector
      

      第 2 步:创建 Solr 核心

       ./bin/solr create -c <corename>-p 8983 -s 3 -rf 3
      

      第 3 步:配置到 Solr

      要索引的mongodb文档中的字段在schema.xml配置文件中指定。在 vi 编辑器中打开 schema.xml。作为

      vi/solr/solr-6.6.2/server/solr/configsets/data_driven_schema_configs/ 
      conf/schema.xml
      

      第 4 步:Mongo 连接器还将与其索引的每个 mongodb 文档关联的元数据存储在字段 ns 和 _ts 中。还将 ns 和 _ts 字段添加到 schema.xml。

      <schema>
      <?xml version="1.0" encoding="UTF-8" ?>
      <schema name="example" version="1.5">
      <field name="time_stamp" type="string" indexed="true"  stored="true"  
      multiValued="false" />
      <field name="category" type="string" indexed="true"  stored="true"  
      multiValued="false" />
      <field name="type" type="string" indexed="true"  stored="true"  
      multiValued="false" />
      <field name="servername" type="string" indexed="true"  stored="true"  
      multiValued="false" />
      <field name="code" type="string" indexed="true"  stored="true"  
      multiValued="false" />
      <field name="msg" type="string" indexed="true"  stored="true"  
      multiValued="false" />
      <field name="_ts" type="long" indexed="true" stored="true" />
      <field name="ns" type="string" indexed="true" stored="true"/>
       <field name="_version_" type="long" indexed="true" stored="true"/>
      
      </schema>
      

      第五步:我们还需要配置 solrconfig.xml 中的 org.apache.solr.handler.admin.LukeRequestHandler 请求处理程序。

      在 vi 编辑器中打开 solrconfig.xml。

       vi ./solr-5.3.1/server/solr/configsets/basic_configs/conf/solrconfig.xml
      

      为 Mongo 连接器指定请求处理程序。

      *<requestHandler name="/admin/luke" 
      class="org.apache.solr.handler.admin.LukeRequestHandler" />*
      

      还将自动提交配置为 true,以便 Solr 在配置的时间后自动提交来自 MongoDB 的数据。

      <autoCommit>
      <maxTime>15000</maxTime>
      <openSearcher>true</openSearcher>
      </autoCommit>
      

      第6步:Solr需要重启

      Bin/solr restart -force
      

      启动 MongoDB 服务器 Mongo 连接器需要运行 MongoDB 副本集才能在 Solr 中索引 MongoDB 数据。副本集是实现复制和自动故障转移的 MongoDB 服务器集群。副本集可以仅包含单个服务器,端口指定为 27017,MongoDB 的数据目录指定为 /data/db,副本集名称使用 –replSet 选项指定为 rs0。

      Sudo mongod --port 27017 --dbpath /data/db --replSet rs0
      

      第 7 步:启动 MongoDB Shell 使用以下命令启动 Mongodb shell

      Mongo
      

      MongoDB shell 启动。我们需要启动副本集。运行以下命令启动副本集。

       rs.initiate()
      

      第 8 步:启动 MongoDB 连接器并使用 Solr 索引 MongoDB 数据库 运行 Mongo-connector 命令如下

      mongo-connector --unique-key=id –n solr.wlslog -m localhost:27017 -t 
      http://xx.xxx.xxx.xx:8983/solr/wlslog -d solr_doc_manager
      

      在上述声明中 solr.wlslog--> solr 是数据库名 wlslog 是集合名 Solr/wlslog--> wlslog 是一个 CORE 名称

      为了将来的参考,请使用以下链接 https://www.toadworld.com/platforms/nosql/b/weblog/archive/2017/02/03/indexing-mongodb-data-in-apache-solr

      【讨论】:

        猜你喜欢
        • 2013-05-22
        • 2014-10-27
        • 1970-01-01
        • 2012-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-23
        相关资源
        最近更新 更多