Elasticsearch _update_by_query (一)

Elasticsearch   Update By Query : 在现有索引 上重建

1 创建文档1

PUT book/_doc/1
{
  "content":"SAP Material mangagement",
  "keyword":"SAP"
}

2.更改索引

PUT book/_mapping
{
  "properties":{
    "content":{
      "type":"text",
      "fields":{
        "english":{
          "type":"text",
          "analyzer":"english"
        }
      }
    }
  }
}

3 创建文档2

PUT book/_doc/2
{
  "content":"Oracle database 12 management",
  "keyword":"oracle"
}

4. 搜索文档2

POST book/_search
{
  "query":{
    "match": {
      "content.english": "Oracle"
    }
  }
}

5. 搜索文档1  找不到

POST book/_search
{
  "query":{
    "match": {
      "content.english": "SAP"
    }
  }
}

6. _update_by_query 

POST book/_update_by_query
{}

7. 搜索文档1 可以找到

POST book/_search
{
  "query":{
    "match": {
      "content.english": "SAP"
    }
  }
}
posted on 2021-11-15 19:03  InnoLeo  阅读(631)  评论(0编辑  收藏  举报