elasticsearch
查询所有文档:
curl -XGET 'http://192.168.1.34:9200/_search?pretty'
按索引查询所有文档:
curl -XGET 'http://192.168.1.34:9200/{index_name}/_search?pretty'
按条件查询文档:
curl -XGET 'http://192.168.1.34:9200/{index_name}/_search?q={field_name}:{search_query}&pretty'
使用查询DSL查询文档:
curl -XGET 'http://192.168.1.34:9200:9200/{index_name}/_search?pretty' -H 'Content-Type: application/json' -d '{"query": {"match": {"field_name": "search_query"}}}'
其中,{index_name}是要查询的索引名称,{field_name}是要查询的字段名称,{search_query}是要搜索的关键字或短语。在第4个示例中,查询DSL被包含在HTTP请求正文中,可以使用-d选项指定。
获取 Elasticsearch 中所有索引的名称和总数:
curl -XGET 'http://localhost:9200/_cat/indices
查看集群快照信息
curl -XGET 'http://192.168.1.34:9200/_snapshot?pretty'
删除elasticsearch索引命令
实例删除appfac_history_b81ab1497ae1133dbc41e584912d77aa
curl -X DELETE "http://10.50.11.131:9200/appfac_history_b81ab1497ae1133dbc41e584912d77aa" -H 'Content-Type: application/json' -u elastic:S3dp7hDm