安装
解压相关的压缩包,定位到bin文件夹下
命令:elasticsearch
jdk必须是1.8以上的
然后等9300,9200两个端口都启动成功
java开发使用9300,其他开发使用9200
创建索引库
在postman输入地址(提交方式是PUT)
http://localhost:9200/索引库名
如http://localhost:9200/tensquare_elasticsearch,创建名为tensquare_elasticsearch的索引库
简单的操作
新建文档
直接在地址后面跟文档名,然后通过JSON传数据,ID自动生成,提交方式为POST
http://localhost:9200/索引库名/文档名
如http://localhost:9200/tensquare_elasticsearch/article,在tensquare_elasticsearch索引库创建一个名为article的文档
参数为Json,如
{
"title":"spring教程",
"content":"spring框架教程"
}
查询所有(提交方式为GET)
http://localhost:9200/索引库名/文档名/_search
修改(提交方式为PUT)
http://localhost:9200/索引库名/文档名/id
(若ID不存则重新创建一条)
参数为Json,如
{
"title":"spring教程",
"content":"spring框架教程"
}
根据ID查询(提交方式为GET)
http://localhost:9200/索引库名/文档名/id
按条件查询(会模糊查询(对词条,不对单字,会分词),提交方式为GET)
http://localhost:9200/索引库名/文档名/_search?q=字段名:数值
如http://localhost:9200/tensquare_elasticsearch/article/_search?q=content:教程,查询content字段里面有“教程”两个字的
模糊查询(正常的整体模糊匹配,提交方式为GET)
http://localhost:9200/索引库名/文档名/_search?q=字段名:*数值*