将Solr节点导出到Elasticsearch索引
项目描述
Solr到Elasticsearch迁移器
这将把Solr节点迁移到Elasticsearch索引。
需求
- Python 3+
- elasticsearch
- pysolr
用法
usage: solr-to-es [-h] [--solr-query SOLR_QUERY] [--solr-fields COMMA_SEP_FIELDS]
[--rows-per-page ROWS_PER_PAGE] [--es-timeout ES_TIMEOUT]
solr_url elasticsearch_url elasticsearch_index doc_type
以下示例将遍历本地Solr上的所有文档,并将它们提交到本地Elasticsearch服务器上的索引es_index
,文档类型为solr_docs
。
solr-to-es http://localhost:8983/solr/<<collection_name>> http://localhost:9200 <<collection_name>> solr_docs
solr_url
是您的Solr的完整URL,
elasticsearch_url
是您的Elasticsearch服务器的URL。
elasticsearch_index
是您将在Elasticsearch上提交Solr文档的索引。
doc_type
是Elasticsearch假设您正在导入的文档类型。
--solr-query
默认为*:*
--solr-fields
默认为
(即所有字段)
--rows-per-page
默认为500
--es-timeout
默认为60
--es-user
用于Elasticsearch的认证
--es-password
用于Elasticsearch的认证
--es-max-retries
当收到429时,文档将重试的最大次数,设置为0表示在429上不重试
--es-initial-backoff
我们在第一次重试之前应等待的秒数。任何后续的重试都将为initial_backoff * 2**retry_number的幂
安装
运行python setup.py install
来安装脚本。
演示
以下是一个从Plos.org API抓取关于动物的超过11.4万篇期刊文章的示例。
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch
solr-to-es --solr-query animal http://api.plos.org/search localhost:9200 es_plos solr_docs
curl http://localhost:9200/_cat/indices?v
注意:您可能会从脚本中获得403禁止访问错误,这是因为solr.quepid.com不允许深度分页,但是您的ES集群中会有文档.
项目详情
关闭
pds.solr_to_es-0.3.0-py3-none-any.whl的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cfeea2e901876921ce43f0e0b17449c5095d90c8b1f156196060bc07944c09d4 |
|
MD5 | 1f226abd7e6249bc256c73625aa2a7cc |
|
BLAKE2b-256 | 77d5e63532882cd7a57cd10db16ec3ebe7daf31f8a2d0454d4643799fa8d0fb3 |