美文网首页
elasticsearch初使用

elasticsearch初使用

作者: 随记草堂 | 来源:发表于2020-09-17 00:43 被阅读0次

    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. 简单查询

    相关文章

      网友评论

          本文标题:elasticsearch初使用

          本文链接:https://www.haomeiwen.com/subject/fgpkyktx.html