Elasticsearch http://www.ruanyifeng.com/blog/2017/08/elasticsearch.html https://cloud.tencent.com/developer/article/1547867 https://www.cnblogs.com/biehongli/p/11710704.html api操作 Elasticsearch 是基于Lucene开发的一个分布式全文检索框架,向Elasticsearch中存储和从Elasticsearch中查询,格式是json。 向Elasticsearch中存储数据,其实就是向es中的index下面的type中存储json类型的数据。 7.15.1 http://localhost:9200 Elastic 返回一个 JSON 对象,包含当前节点、集群、版本等信息。 http://localhost:9200/elasticsearch http://localhost:9200/_cat http://localhost:9200/_cat/health?v 查看集群的健康状况 http://localhost:9200/_cat/indices?v 查看所有索引 一,http://localhost:9200/xmhindex PUT 方式提交,新建索引 返回: { "acknowledged": true, "shards_acknowledged": true, "index": "xmhindex" } 二,索引一个文档到 xmhindex 索引中 PUT 方式提交 1) 指定id http://localhost:9200/xmhindex/_doc/1?pretty" -H 'Content-Type: application/json' -d' { "name": "John Doe" }' 返回: { "_index": "xmhindex", "_type": "_doc", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 0, "_primary_term": 1 } 2)不指定id http://localhost:9200/xmhindex/_doc POST { "name": "xingxmh" } 三,从 xmhindex 索引中获取指定id的文档 1)http://localhost:9200/xmhindex/_doc/1?pretty 返回: { "_index" : "xmhindex", "_type" : "_doc", "_id" : "1", "_version" : 1, "_seq_no" : 0, "_primary_term" : 1, "found" : true, "_source" : { "name" : "John Doe" } } 2) 查询所有 http://localhost:9200/xmhindex/_doc/_search GET 方式 四,删除记录 http://localhost:9200/xmhindex/_doc/Q6cjjnwBKUvN8NOwHRUo DELETE 方式 五,全文搜索 http://localhost:9200/xmhindex/_doc/_search 全匹配 { "query" : { "match" : { "name" : "xingminghui" }} } 模糊匹配 { "query": { "fuzzy": { "name" : "xingminghui" } } } https://www.elastic.co/guide/cn/elasticsearch/guide/current/fuzzy-query.html