• 【十次方基础教程(后台)】安装ElasticSearch并使用


    安装

    解压相关的压缩包,定位到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=字段名:*数值*

  • 相关阅读:
    20175126《Java程序设计》第七周学习总结
    20175126《Java程序设计》第六周学习总结
    软工实践个人总结
    第06组 Beta版本演示
    第06组 Beta冲刺(4/5)
    第06组 Beta冲刺(5/5)
    第06组 Beta冲刺(3/5)
    第06组 Beta冲刺(2/5)
    第6组 Beta冲刺(1/5)
    第06组 Alpha事后诸葛亮
  • 原文地址:https://www.cnblogs.com/IceBlueBrother/p/10855239.html
Copyright © 2020-2023  润新知