【问题标题】:How to create an index from search results, all on the server?如何从搜索结果创建索引,全部在服务器上?
【发布时间】:2017-03-06 04:59:54
【问题描述】:

我将从过滤后的查询中获取文档(相当多的文档)。然后我将立即从它们创建一个索引(在 Python 中,使用requests 直接查询 REST API),无需任何修改。

是否可以直接在服务器上进行此操作,而无需数据往返脚本和返回?

Another question 类似(在意图上),唯一的答案是通过 Logstash(相当于使用我的代码,尽管可能更有效)

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    参考http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/reindex.html

    简而言之,您需要做的是 0.) 确保您将 _source 设置为 true

    1.) 使用扫描和滚动 API,通过搜索类型扫描传递过滤后的查询,

    2.) 使用滚动 ID 获取文档

    2.) 使用返回用于索引数据的 json 的源字段对结果进行批量索引

    参考: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/scan-scroll.html

    guide/en/elasticsearch/guide/current/bulk.html

    guide/en/elasticsearch/guide/current/reindex.html

    【讨论】:

    • 根据我的问题,这本质上就是我打算做的事情。如何确保操作在 elastiscearch 中完成,以避免 fetch-and-push 部分?
    • “在 elastiscearch 内完成”你的意思是你想避免使用网络吗?我不认为你可以避免网络调用,即使你在服务器本身上执行你的程序它仍然会通过 http 与 ES 通信(即使你在 java 中使用传输客户端你仍然在使用网络)。
    【解决方案2】:

    es 2.3 有一个实验性功能,允许从查询中重新索引 https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-20
      • 2012-04-10
      • 1970-01-01
      • 2011-04-22
      • 2017-07-12
      • 2019-03-01
      • 2021-11-13
      • 1970-01-01
      相关资源
      最近更新 更多