带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(3)

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: 带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(3)

 《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(2) https://developer.aliyun.com/article/1231070



新增字段

 

POST /my_goods/_update/1
{
  "doc": {
    "shopName": "小王店铺"
  }
}

修改店铺名称为:“张三店铺”

 

POST /my_goods/_update/1
{
  "doc": {
    "shopName": "张三店铺"
  }
}
{
  "goodsName" : "苹果 51英寸 4K超高清",
  "skuCode" : "skuCode1",
  "brandName" : "苹果",
  "closeUserCode" : [
    "0"
  ],
  "channelType" : "cloudPlatform",
  "shopCode" : "sc00001",
  "publicPrice" : "8188.88",
  "groupPrice" : null,
  "boxPrice" : null,
  "boostValue" : 1.8,
  "shopName" : "张三店铺"
}
另外还可以使用 PUT 进行修改,只不过需要罗列所有字段:
PUT my_goods/_doc/10
{
  "goodsName": "三星UA55RU7520JXXZ 52英寸 4K超高清",
  "skuCode": "skuCode10",
  "brandName": "三星",
  "closeUserCode": [
    "uc0022"
  ],
  "channelType": "cloudPlatform",
  "shopCode": "sc00001",
  "publicPrice": "8288.88",
  "groupPrice": null,
  "boxPrice": [
    {
      "boxType": "box1",
      "boxUserCode": [
        "uc0022"
      ],
      "boxPriceDetail": 4288.88
    }
  ],
  "boostValue": 1.8
}
用脚本同样能实现更新操作:
POST my_goods/_update/10
{
  "script": {
    "source": "ctx._source.city=params.channelType",
    "lang": "painless",
    "params": {
      "channelType": "cloudPlatform1"
    }
  }
}
Update by query
更新操作还可以使用 _update_by_query API,当店铺编码为 sc00002 时修改 publicPrice 为 5888.00 元。
插入文档 ID 为 2 的店铺商品信息:
POST /my_goods/_create/2
{
  "goodsName": "苹果 55英寸 3K超高清",
  "skuCode": "skuCode2",
  "brandName": "苹果",
  "closeUserCode": [
    "0"
  ],
  "channelType": "cloudPlatform",
  "shopCode": "sc00002",
  "publicPrice": "6188.88",
  "groupPrice": null,
  "boxPrice": null,
  "boostValue": 1

此时查询返回


{
  "goodsName" : "苹果 55英寸 3K超高清",
  "skuCode" : "skuCode2",
  "brandName" : "苹果",
  "closeUserCode" : [
    "0"
  ],
  "channelType" : "cloudPlatform",
  "shopCode" : "sc00002",
  "publicPrice" : "6188.88",
  "groupPrice" : null,
  "boxPrice" : null,
  "boostValue" : 1.0
}

更新当店铺编码为 sc00002 时修改 publicPrice 为 5888.00 元


POST /my_goods/_update_by_query
{
  "script": {
    "source": "ctx._source.publicPrice=5888.00",
    "lang": "painless"
  },
  "query": {
    "term": {
      "shopCode": "sc00002"
    }
  }
}

再次查询结果

 

GET /my_goods/_source/2
{
  "shopCode" : "sc00002",
  "brandName" : "苹果",
  "closeUserCode" : [
    "0"
  ],
  "groupPrice" : null,
  "boxPrice" : null,
  "channelType" : "cloudPlatform",
  "boostValue" : 1.0,
  "publicPrice" : 5888.0,
  "goodsName" : "苹果 55英寸 3K超高清",
  "skuCode" : "skuCode2"
}

Reindex

 

当有业务需要重建索引时需要用到 _reindex API。

 

索引的来源和目的地,必须是已经存在的 index、index alias 或者 data stream。

 

你可以简单的将索引 A reindex 到索引 B,当然也可以带条件的 reindex 到索引 B。

 

如下所示,将 skuCode=skuCode2 的商品信息 reindex 到索引 my_goods_new 中


POST _reindex
{
  "source": {
    302         >   三、产品能力
    "index": "my_goods",
    "query": {
      "match": {
        "skuCode": "skuCode2"
      }
    }
  },
  "dest": {
    "index": "my_goods_new"
  }
}


《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(4) https://developer.aliyun.com/article/1231067

相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
12月前
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(16)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(16)
|
12月前
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(18)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(18)
|
12月前
|
项目管理 索引 微服务
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(20)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(20)
|
12月前
|
自然语言处理 索引
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(12)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(12)
|
12月前
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(7)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(7)
|
12月前
|
索引
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(15)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(15)
|
12月前
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(8)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(8)
|
12月前
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(14)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(14)
|
12月前
|
缓存
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(10)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(10)
|
12月前
|
定位技术
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(19)
带你读《Elastic Stack 实战手册》之18:——3.4.2.3.Search通过Kibana(19)

相关课程

更多