Elasticsearch支持多种查询和更新操作。以下是一些常见的查询和更新操作示例:
-
查询所有文档:
-
根据条件查询文档:
GET /index_name/_search
{
"query": { "match": { "field_name": "search_term" } } }
-
更新文档:
POST /index_name/_update/document_id
{
"doc": { "field_name": "new_value" } }
-
条件更新文档:
POST /index_name/_update_by_query
{
"query": { "match": { "field_name": "search_term" } }, "script": { "source": "ctx._source.field_name = 'new_value'" } }
curl命令:
curl -XPOST localhost:9200/alert*/_update_by_query?pretty -d '{"query":{"bool":{"must":[{"range":{"first_alert_time":{"gte":"2023-07-23 00:00:00","lt":"2023-08-24 00:00:00"}}}]}},"script":{"inline":"ctx._source.origin_alert_cat_cd=103006"}}
这些示例仅涵盖了一小部分Elasticsearch的查询和更新操作。Elasticsearch提供了丰富的查询和更新功能,可以根据具体需求进行进一步的定制和扩展。标签:00,name,更新,查询,Elasticsearch,query From: https://www.cnblogs.com/shangwei/p/17652079.html