4 Star 55 Fork 25

西川吴少 / ruoyi-cloud-es

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

平台简介

*基于RuoYi-cloud3.5.0 + elasticsearch7的搜索引擎演示项目,使用2个经典案例(百度地图找房+文章内容搜索),演示es常用的功能及代码原生写法和简化写法(easy-es)~

记得右上角点个 star 持续关注更新哟~~

内置功能

后台页面

    1. 房源信息:支持后台添加,修改,删除,编辑房源信息 前台页面
    1. 聚合统计:统计每个区域每个小区房源个数。
    1. 搜索提示(search-as-you-type):根据输入文字动态弹出提示内容。
    1. 地图找房:使用百度地图显示房源信息,地图拖拽和缩放变更房源数据。

在线体验

页面功能展示

QQ交流群

启动说明

需要对以下模块进行启动 启动顺序随意

  • RuoYiAuthApplication
  • RuoYiSystemApplication
  • RuoYiGatewayApplication
  • RuoYiNewsApplication( 租房模块 )
  • RuoYiFileApplication( 文件服务 )

友情链接

插件版本

  • RuoYi-Cloud 3.5.0
  • Nacos 2.0.2
  • Node.js 14.0.0
  • npm 6.14.4
  • elasticsearch 7.14.1

环境安装

1.1 安装docker

    yum install -y yum-utils

  # 阿里云地址(国内地址,相对更快)
  yum-config-manager \
      --add-repo \
      http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  yum install docker-ce docker-ce-cli containerd.io


  docker version # 查看Docker版本信息

  systemctl status docker		# 查看 docker 服务状态

  systemctl start docker		# 启动 docker 服务:
  systemctl stop docker		# 停止 docker 服务:
  systemctl status docker		# 查看 docker 服务状态
  systemctl restart docker	# 重启 docker 服务

  vim /etc/docker/daemon.json
  # 添加如下内容,可以自己替换。默认地址是我的创建的
  {
    "registry-mirrors": ["https://mr63yffu.mirror.aliyuncs.com"]
  }

  systemctl daemon-reload
  systemctl restart docker	# 重启 docker 服务

1.2 安装docker-compose

  curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

  # 将可执行权限应用于该二进制文件
  sudo chmod +x /usr/local/bin/docker-compose

  docker-compose --version

1.3 安装es

执行命令

mkdir -p /data/docker_data/es-kabana
mkdir -p /data/docker_data/es-kabana/es/config
touch    /data/docker_data/es-kabana/docker-compose.yml
touch    /data/docker_data/es-kabana/es/config/elasticsearch.yml
vim      /data/docker_data/es-kabana/docker-compose.yml
vim      /data/docker_data/es-kabana/es/config/elasticsearch.yml
cd /data/docker_data/es-kabana
docker-compose up -d 开启es
docker-compose down 关闭es

docker-compose.yml内容如下:

version: '3'

# 网桥es -> 方便相互通讯
networks:
  es:

services:
  elasticsearch:
    image: registry.cn-hangzhou.aliyuncs.com/zhengqing/elasticsearch:7.14.1      # 原镜像`elasticsearch:7.14.1`
    container_name: elasticsearch             # 容器名为'elasticsearch'
    restart: unless-stopped                           # 指定容器退出后的重启策略为始终重启,但是不考虑在Docker守护进程启动时就已经停止了的容器
    volumes:                                  # 数据卷挂载路径设置,将本机目录映射到容器目录
      - "./es/data:/usr/share/elasticsearch/data"
      - "./es/logs:/usr/share/elasticsearch/logs"
      - "./es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
      - "./es/plugins/:/usr/share/elasticsearch/plugins"
    environment:                              # 设置环境变量,相当于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xmx512m -Xms512m"
      ELASTIC_PASSWORD: "123456" # elastic账号密码
    ports:
      - "9202:9200"
      - "9302:9300"
    networks:
      - es

  kibana:
    image: registry.cn-hangzhou.aliyuncs.com/zhengqing/kibana:7.14.1       # 原镜像`kibana:7.14.1`
    container_name: kibana
    restart: unless-stopped
    volumes:
      - ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
      - ./kibana/logs:/usr/share/kibana/logs
    environment:
      TZ: Asia/Shanghai    # 更改容器时区为 CST(默认为UTC)
      LANG: en_US.UTF-8
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    networks:
      - es
  elasticsearch-head:
    image: wallbase/elasticsearch-head:6-alpine
    container_name: elasticsearch-head
    restart: unless-stopped
    environment:
      TZ: 'Asia/Shanghai'
    ports:
      - '9100:9100'
    networks:
      - es

elasticsearch.yml内容如下:

cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.port: 9200
# 开启es跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,Content-Type
# 开启安全控制
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true

1.4安装中文分词

先去github下载分词包elasticsearch-analysis-ik-7.14.1.zip

然后解压到该目录下/data/docker_data/es-kabana/es/plugins/analysis-ik-7.14.1

启动说明

一.启动前数据准备,创建es索引

1.1 创建文章内容索引article

请求方式:PUT (请使用postman进行访问)

请求地址:http://127.0.0.1:9202/article

请求内容:(请使用postman进行访问)

{
  "settings": {
    "number_of_replicas": 0
  },
  "mappings": {
    "dynamic": false,
    "properties": {
        "publishTime": {
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
          "type": "date"
        },
        "articleCover": {
          "type": "keyword"
        },
        "articleType": {
          "type": "integer"
        },
        "publishUserId": {
          "type": "keyword"
        },
        "title": {
          "analyzer": "ik_smart",
          "type": "text"
        },
        "categoryId": {
          "type": "integer"
        }
      }
  }
}

参数说明:

number_of_replicas": 0  <!-- 副本数设置为0 -->

正确返回:

{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "article"
}

1.2 创建地图找房索引xunwu

请求方式:PUT (请使用postman进行访问)

请求地址:http://127.0.0.1:9202/xunwu

请求内容:(请使用postman进行访问)

{
  "settings": {
    "number_of_replicas": 0
  },
  "mappings": {
    "dynamic": false,
    "properties": {
      "id": {
        "type": "long"
      },
      "houseId": {
        "type": "long"
      },
      "title": {
        "type": "text",
        "analyzer": "ik_smart",
        "search_analyzer": "ik_smart"
      },
      "price": {
        "type": "integer"
      },
      "area": {
        "type": "integer"
      },
      "createTime": {
        "type": "date",
        "format": "strict_date_optional_time||epoch_millis"
      },
      "lastUpdateTime": {
        "type": "date",
        "format": "strict_date_optional_time||epoch_millis"
      },
      "cityEnName": {
        "type": "keyword"
      },
      "regionEnName": {
        "type": "keyword"
      },
      "direction": {
        "type": "integer"
      },
      "distanceToSubway": {
        "type": "integer"
      },
      "subwayLineName": {
        "type": "keyword"
      },
      "subwayStationName": {
        "type": "keyword"
      },
      "tags": {
        "type": "text"
      },
      "street": {
        "type": "keyword"
      },
      "district": {
        "type": "keyword"
      },
      "description": {
        "type": "text",
        "analyzer": "ik_smart",
        "search_analyzer": "ik_smart"
      },
      "layoutDesc" : {
        "type": "text",
        "analyzer": "ik_smart",
        "search_analyzer": "ik_smart"
      },
      "traffic": {
        "type": "text",
        "analyzer": "ik_smart",
        "search_analyzer": "ik_smart"
      },
      "roundService": {
        "type": "text",
        "analyzer": "ik_smart",
        "search_analyzer": "ik_smart"
      },
      "rentWay": {
        "type": "integer"
      },
      "suggest": {
        "type": "completion"
      },
      "location": {
        "type": "geo_point"
      }
    }
  }
}

参数说明:

number_of_replicas": 0  <!-- 副本数设置为0 -->

正确返回:

{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "xunwu"
}

1.3 删除索引 (此步不需要执行)

请求方式:DELETE (请使用postman进行访问)

请求地址:http://127.0.0.1:9202/article

正确返回:

{
    "acknowledged": true
}

1.4 将租房数据从mysql中同步到es(访问该接口即可)

请求方式:GET (请使用postman进行访问)

请求地址:http://127.0.0.1:9205/rent/houseDataToEs

正确返回:

{
    "code": 200,
    "message": "OK",
    "data": "success",
    "more": false
}

一.百度地图相关

1.1 申请百度地图ak

(本地运行可以不申请,项目部署服务器则需要申请)

浏览器访问https://lbsyun.baidu.com/ 点击控制台 先进行个人实名认证

认证成功后进入控制台 点击 应用管理 我的应用

点击创建应用 填写以下内容 其他默认

创建浏览器端ak

应用名称:

xunwu-web

应用类型:

浏览器端

请求校验方式:

IP白名单校验

Referer白名单:

0.0.0.0,127.0.0.1,localhost,192.168.1.83,49.232.18.37

创建服务器端ak

应用名称:

xunwu-server

应用类型:

服务端

请求校验方式:

IP白名单校验

Referer白名单:

0.0.0.0/0,0.0.0.0,127.0.0.1,49.232.18.37

1.2在代码中替换ak为刚才申请的ak

将下面代码文件39行替换为刚才申请的服务器端ak

https://gitee.com/avatarwx/ruoyi-cloud-es/blob/master/ruoyi-modules/ruoyi-modules-news/src/main/java/com/ruoyi/news/service/house/AddressServiceImpl.java

将下面代码文件90行替换为刚才申请的浏览器端ak

https://gitee.com/avatarwx/ruoyi-cloud-es/blob/master/ruoyi-modules/ruoyi-modules-news/src/main/resources/templates/rent-map.html

1.3如果地图加载不出来,请关闭你的代理或者vpn.

MIT License Copyright (c) 2022 西川吴少 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于RuoYi-cloud3.5.0 + elasticsearch7的搜索引擎演示项目,使用2个经典案例(百度地图找房+文章内容搜索),演示es常用的功能及代码原生写法和简化写法(easy-es)~支持高亮,分词,Geo等功能 展开 收起
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/avatarwx/ruoyi-cloud-es.git
git@gitee.com:avatarwx/ruoyi-cloud-es.git
avatarwx
ruoyi-cloud-es
ruoyi-cloud-es
master

搜索帮助