Mongo连接器的Solr插件
solr-doc-manager的Python项目详细描述
开始
安装
此包是mongo-connector的文档管理器。
最简单的方法是同时安装solr doc manager 作为Mongo连接器,pip:
pip install mongo-connector[solr]
如果您已经安装了Mongo连接器,请通过:
pip install solr-doc-manager
您还可以安装solr doc manager的开发版本 手动:
git clone https://github.com/mongodb-labs/solr-doc-manager cd solr-doc-manager python setup.py install
您可能必须使用sudo运行python setup.py install,具体取决于 安装Mongo连接器的位置以及您拥有的特权。
有关使用solr运行mongo连接器的信息,请参见https://github.com/mongodb-labs/mongo-connector/wiki/Usage%20with%20Solr
注意
请注意,在Mongo连接器版本2.5.0之前,Solr文档管理器与Mongo连接器一起打包。
运行测试
要求
- solr doc manager github存储库的副本
The tests are not included in the package from PyPI and can only be acquired by cloning this repository on Github:
git clone https://github.com/mongodb-labs/solr-doc-manager
- solr
The integration tests require Solr to be running. To set up and run Solr:
curl -O http://archive.apache.org/dist/lucene/solr/4.9.1/solr-4.9.1.tgz tar -zxf solr-4.9.1.tgz cp mongo_connector/doc_managers/schema.xml solr-4.9.1/example/solr/collection1/conf/ cd solr-4.9.1/example/ && java -Djetty.port=8983 -Dsolr.solr.home=solr -jar start.jar > /dev/null 2>&1 &Solr will be running on http://localhost:8983/solr
- Mongo编排
Mongo Connector runs MongoDB on its own using another tool called Mongo Orchestration. This package should install automatically if you run ^{tt3}$, but the Mongo Orchestration server still needs to be started manually before running the tests:
mongo-orchestration --bind 127.0.0.1 --config orchestration.config startwill start the server. To stop it:
mongo-orchestration --bind 127.0.0.1 --config orchestration.config stopThe location of the MongoDB server should be set in orchestration.config. For more information on how to use Mongo Orchestration, or how to use it with different arguments, please look at the Mongo-Orchestration README.
- 环境变量
There are a few influential environment variables that affect the tests. These are:
- ^{tt4}$ is the username to use if running the tests with authentication enabled.
- ^{tt5}$ is the password for the above.
- ^{tt6}$ is the starting port for running MongoDB. Future nodes will be started on sequentially increasing ports.
- ^{tt7}$ is the address on which Solr is running.
- ^{tt8}$ is the address to use for Mongo Orchestration (i.e. hostname:port)
所有测试都位于tests目录中。
在命令行上运行测试
虽然测试会自行设置和拆除MongoDB集群,但在进行完整的测试运行之前,请确保启动Solr!
您可以使用一个命令运行所有测试(这在所有受支持的python版本中都有效):
python setup.py test
此外,您还可以选择运行哪些测试(仅限python>;2.6)!例如,如果您只想运行solr doc manager测试:
python -m unittest tests.test_solr_doc_manager
错误消息
有些测试旨在生成大量ERROR级别的日志消息,特别是回滚测试。mongo connector记录在oplog中迭代光标时遇到的异常,因此我们在mongodb集群在测试中被分离时在控制台输出中看到这些异常。只要所有的测试都通过,并且有一条消息,一切都很好。