跳转到主要内容

将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 (6.0 kB 查看哈希)

上传时间 Python 3

支持