简体   繁体   English

如何从搜索查询中插入数据以进行弹性搜索

[英]How to insert data to elastic search from search query

I try to copy some data from one elastic db to another elasticsearch db, is there any way to insert data from query results? 我尝试将一些数据从一个Elastic db复制到另一个elasticsearch db,有什么方法可以从查询结果中插入数据?

Example of results: 结果示例:

{
  "took": 29,
  "timed_out": false,
  "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
  },
  "hits": {
  "total": 572,
  "max_score": 1,
  "hits": [
    {
      "_index": "ref",
      "_type": "dic",
      "_id": "12345",
      "_score": 1,
      "_source": {
        "name": "Test name"
      }
    },
    ...
  ]
}

In each db mapping is equals. 在每个数据库中映射是相等的。

I fork some project witch make a bulk data for elasticsearch, json-to-es-bulk 我分叉一些项目女巫为elasticsearch, json-to-es-bulk制作大量数据

I it's compability with 5.6 es version, you can use it in 2 variants: 我与5.6 es版本兼容,可以在2个版本中使用它:

`node index.js -f inputdata.json --index newIndexName --type newIndexType --rewrite true`

or 要么

`node index.js -f inputdata.json --index --type --rewrite false`

after run, you'll see a file request-data.txt, just use it to POST /_bulk [request-data.txt content] 运行后,您会看到一个文件request-data.txt,只需将其用于POST /_bulk [request-data.txt content]

Input data json file must contains an array of search hits, like this: 输入数据json文件必须包含搜索命中数组,如下所示:

[ { "_index": "oldIndexName", "_type": "oldIndexName", "_id": "SOME_ID-HiTfm", "_score": 1, "_source": { "orderNumber": "2984", "refId": "SOME_VALUE" } }, ... ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM