elasticsearch初使用

elasticsearch下载安装

    elasticsearch以下相关内容安装

原创链接:https://www.cnblogs.com/hualess/p/11540477.html

  1. 下载地址

    https://www.elastic.co/cn/downloads/elasticsearch



  2. 解压下载好的压缩包

    找到config文件夹的elasticsearch.yml,添加两行内容:

    http.cors.enabled: true 

    http.cors.allow-origin: "*"

  3. 启动elasticsearch

    bin---》elasticsearch.bat 双击启动

elasticsearch-head下载安装

    elasticsearch的客户端工具

  1. 使用elasticsearch-head之前需要安装node.js

  2. node.js下载地址

    https://nodejs.org/en/download/

  3. 安装node.js

    一路默认安装,安装地址可以自行修改。 安装时有一个勾选项,是否添加到path路径,记得勾上。

  4. 下载elasticsearch-head

    https://github.com/mobz/elasticsearch-head

    下载zip压缩包

  5. 解压进入文件夹

    在该文件夹目录下,打开命令窗口,运行命令: npm install

    安装grunt:  npm install -g grunt-cli

    head 用grunt启动,所以需要安装

  6. 启动elasticsearch

    运行命令: npm run start

    访问地址:http://localhost:9100

java代码调用

    maven项目,引入jar包

    使用RestHighLevelClient 连接elasticsearch

    关于RestHighLevelClient 的初始化配置等,

原创链接 :https://blog.csdn.net/qq1107533660/article/details/83347358


  1. 批量导入

    indexName: 索引

    table: 因elasticsearch6.X之后弱化了type 类型的概念, 此处参数为了区分不通的索引

    idName: 数据id名字

    bulks: list数组,数组元素,此处为Map,实体类对象应该也是可以


  2. 简单查询


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容