ElasticSearch 6.x 学习笔记:8.路由机制

2022-05-06 19:09:26 浏览数 (1)

代码语言:javascript复制
PUT blog/csdn/3?routing=chengyuqiang
{
  "id":3,
  "title":"Java简介",
  "author":"chengyuqiang",
  "content":"Oracle Java"
}
代码语言:javascript复制
{
  "_index": "blog",
  "_type": "csdn",
  "_id": "3",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
  },
  "created": true
}

查询

代码语言:javascript复制
GET blog/_search?routing=chengyuqiang
代码语言:javascript复制
{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "blog",
        "_type": "csdn",
        "_id": "3",
        "_score": 1,
        "_routing": "chengyuqiang",
        "_source": {
          "id": 3,
          "title": "Java简介",
          "author": "chengyuqiang",
          "content": "Oracle Java"
        }
      }
    ]
  }
}

删除

代码语言:javascript复制
DELETE blog/csdn/3
代码语言:javascript复制
{
  "found": false,
  "_index": "blog",
  "_type": "csdn",
  "_id": "3",
  "_version": 1,
  "result": "not_found",
  "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
  }
}
代码语言:javascript复制
DELETE blog/csdn/3?routing=hadron
代码语言:javascript复制
{
  "found": false,
  "_index": "blog",
  "_type": "csdn",
  "_id": "3",
  "_version": 2,
  "result": "not_found",
  "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
  }
}
代码语言:javascript复制
DELETE blog/csdn/3?routing=chengyuqiang
代码语言:javascript复制
{
  "found": true,
  "_index": "blog",
  "_type": "csdn",
  "_id": "3",
  "_version": 2,
  "result": "deleted",
  "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
  }
}

0 人点赞