Elasticsearch查询文档、修改文档之查改删数据
Elasticsearch查询文档之主键查询、全查询
1、主键查询
GET 请求:
http://127.0.0.1:9200/索引名称/_doc/ID编号
2、全查询
GET 请求:
http://127.0.0.1:9200/索引名称/_search
可以把某个索引中所有的文档数据全部查出
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 6,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "goods",
"_id": "5rUIWX8B3VytjO33NBSb",
"_score": 1,
"_source": {
"title": "小米手机",
"category": "小米",
"images": "https://xiaomi.com/1.png",
"price": 2999
}
},
{
"_index": "goods",
"_id": "1001",
"_score": 1,
"_source": {
"title": "小米手机",
"category": "小米",
"images": "https://xiaomi.com/1.png",
"price": 2999
}
}
]
}
}
Elasticsearch修改文档之全量修改、局部修改、删除数据
1、全量/完全修改
PUT 方式:
http://127.0.0.1:9200/索引名称/_doc/ID编号
修改完后,此时点击查询,可以看到数据已被完全覆盖掉了
1、全量/完全修改
PUT 方式:
http://127.0.0.1:9200/索引名称/_doc/ ID编号
修改完后,此时点击查询,可以看到数据已被完全覆盖掉了
3、删除数据
DELETE 请求:
http://127.0.0.1:9200/索引名称/_doc/ID编号
如果重复删除,则result 则返回not_found
相关文章