赞
踩
Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎。它能很方便的使大量数据具有搜索、分析和探索的能力。充分利用Elasticsearch的水平伸缩性,能使数据在生产环境变得更有价值。Elasticsearch 的实现原理主要分为以下几个步骤,首先用户将数据提交到Elasticsearch 数据库中,再通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据,当用户搜索数据时候,再根据权重将结果排名,打分,再将返回结果呈现给用户。
RestHighLevelClient 底层封装的是一个http连接池,当需要执行 update、index、delete操作时,直接从连接池中取出一个连接,然后发送http请求到ElasticSearch服务端,服务端基于Netty接收请求。
新版本的elasticsearch java client 都推荐用RestHighLevelClient去连接ES集群,放弃掉之前的transport client的方式。
注:spring boot工程
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.2.6</version> </dependency> <!-- fastjson ,json解析工具 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.79</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.27</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.3</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.8.1</version> </dependency> </dependencies>
spring:
application:
name: es_test
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/es_test?serverTimezone=UTC&userUnicode=true&useSSL=false&
username: root
password: root # 修改
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
type-aliases-package: com.king.pojo # 修改
package com.king.config; import org.elasticsearch.client.RestHighLevelClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.client.ClientConfiguration; import org.springframework.data.elasticsearch.client.RestClients; import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; /** * @author King * @version 1.0 * @description es配置 * @date 2023/8/25 14:29 */ @Configuration public class RestClientConfig extends AbstractElasticsearchConfiguration { @Override @Bean public RestHighLevelClient elasticsearchClient() { ClientConfiguration build = ClientConfiguration.builder().connectedTo("localhost:9200").build(); return RestClients.create(build).rest(); } }
package com.king.pojo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @Data @TableName("hotel") public class Hotel { @TableId(type = IdType.INPUT) private Long id; private String name; private String address; private Integer price; private Integer score; private String brand; private String city; private String starName; private String business; private String longitude; private String latitude; private String pic; @TableField(exist = false) private Map<String,String> location; }
/* Navicat Premium Data Transfer Source Server : localhost_3306 Source Server Type : MySQL Source Server Version : 50540 Source Host : localhost:3306 Source Schema : es_test Target Server Type : MySQL Target Server Version : 50540 File Encoding : 65001 Date: 26/08/2023 16:35:24 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for hotel -- ---------------------------- DROP TABLE IF EXISTS `hotel`; CREATE TABLE `hotel` ( `id` bigint(20) NOT NULL COMMENT '酒店id', `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '酒店名称', `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '酒店地址', `price` int(10) NOT NULL COMMENT '酒店价格', `score` int(2) NOT NULL COMMENT '酒店评分', `brand` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '酒店品牌', `city` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所在城市', `star_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '酒店星级,1星到5星,1钻到5钻', `business` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商圈', `latitude` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '纬度', `longitude` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '经度', `pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '酒店图片', PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; -- ---------------------------- -- Records of hotel -- ---------------------------- INSERT INTO `hotel` VALUES (36934, '7天连锁酒店(上海宝山路地铁站店)', '静安交通路40号', 336, 37, '7天酒店', '上海', '二钻', '四川北路商业区', '31.251433', '121.47522', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3E/40/Cii9EVkyLrKIXo1vAAHgrxo_pUcAALcKQLD688AAeDH564_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (38609, '速8酒店(上海赤峰路店)', '广灵二路126号', 249, 35, '速8', '上海', '二钻', '四川北路商业区', '31.282444', '121.479385', 'https://m.tuniucdn.com/fb2/t1/G2/M00/DF/96/Cii-TFkx0ImIQZeiAAITil0LM7cAALCYwKXHQ4AAhOi377_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (38665, '速8酒店上海中山北路兰田路店', '兰田路38号', 226, 35, '速8', '上海', '二钻', '长风公园地区', '31.244288', '121.422419', 'https://m.tuniucdn.com/fb2/t1/G2/M00/EF/86/Cii-Tlk2mV2IMZ-_AAEucgG3dx4AALaawEjiycAAS6K083_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (38812, '7天连锁酒店(上海漕溪路地铁站店)', '徐汇龙华西路315弄58号', 298, 37, '7天酒店', '上海', '二钻', '八万人体育场地区', '31.174377', '121.442875', 'https://m.tuniucdn.com/fb2/t1/G2/M00/E0/0E/Cii-TlkyIr2IEWNoAAHQYv7i5CkAALD-QP2iJwAAdB6245_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (39106, '7天连锁酒店(上海莘庄地铁站店)', '闵行莘庄镇七莘路299号', 348, 41, '7天酒店', '上海', '二钻', '莘庄工业区', '31.113812', '121.375869', 'https://m.tuniucdn.com/fb2/t1/G2/M00/D8/11/Cii-T1ku2zGIGR7uAAF1NYY9clwAAKxZAHO8HgAAXVN368_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (39141, '7天连锁酒店(上海五角场复旦同济大学店)', '杨浦国权路315号', 349, 38, '7天酒店', '上海', '二钻', '江湾、五角场商业区', '31.290057', '121.508804', 'https://m.tuniucdn.com/fb2/t1/G2/M00/C7/E3/Cii-T1knFXCIJzNYAAFB8-uFNAEAAKYkQPcw1IAAUIL012_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (45845, '上海西藏大厦万怡酒店', '虹桥路100号', 589, 45, '万怡', '上海', '四钻', '徐家汇地区', '31.192714', '121.434717', 'https://m.tuniucdn.com/fb3/s1/2n9c/48GNb9GZpJDCejVAcQHYWwYyU8T_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (45870, '上海临港豪生大酒店', '新元南路555号', 896, 45, '豪生', '上海', '四星级', '滴水湖临港地区', '30.871729', '121.81959', 'https://m.tuniucdn.com/fb3/s1/2n9c/2F5HoQvBgypoDUE46752ppnQaTqs_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (46829, '上海浦西万怡酒店', '恒丰路338号', 726, 46, '万怡', '上海', '四钻', '上海火车站地区', '31.242977', '121.455864', 'https://m.tuniucdn.com/fb3/s1/2n9c/x87VCoyaR8cTuYFZmKHe8VC6Wk1_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (47066, '上海浦东东站华美达酒店', '施新路958号', 408, 46, '华美达', '上海', '四钻', '浦东机场核心区', '31.147989', '121.759199', 'https://m.tuniucdn.com/fb3/s1/2n9c/2pNujAVaQbXACzkHp8bQMm6zqwhp_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (47478, '速8酒店(上海松江中心店)', '松江荣乐东路677号', 428, 35, '速8', '上海', '二钻', '佘山、松江大学城', '31.016712', '121.261606', 'https://m.tuniucdn.com/filebroker/cdn/res/07/36/073662e1718fccefb7130a9da44ddf5c_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56201, '上海齐鲁万怡大酒店', '东方路838号', 873, 44, '万怡', '上海', '四星级', '浦东陆家嘴金融贸易区', '31.226031', '121.525801', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/B6/Cii-TF3eXKeIJeN7AASiKHbTtx4AAGRegDSBzMABKJA111_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56214, '上海浦东华美达大酒店', '新金桥路18号', 830, 45, '华美达', '上海', '四星级', '浦东金桥地区', '31.244916', '121.590752', 'https://m.tuniucdn.com/fb3/s1/2n9c/3jtXiuMKZEXJAuKuAkc47yLCjUBt_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56227, '上海圣淘沙万怡酒店', '南桥镇南桥路1号', 899, 45, '万怡', '上海', '四星级', '奉贤开发区', '30.910917', '121.456525', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/B9/Cii-U13eXSiIdJjXAARSA6FywFYAAGRnwHvy1AABFIb158_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56392, '上海银星皇冠假日酒店', '番禺路400号', 809, 47, '皇冠假日', '上海', '五星级', '徐家汇地区', '31.202768', '121.429524', 'https://m.tuniucdn.com/fb3/s1/2n9c/37ucQ38K3UFdcRqntJ8M5dt884HR_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56852, '上海财大豪生大酒店', '武东路188号', 592, 46, '豪生', '上海', '五钻', '江湾/五角场商业区', '31.304182', '121.492936', 'https://m.tuniucdn.com/fb3/s1/2n9c/2jGHezLZvPZqC9cBGesbP5vAhCXi_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56912, '上海华凯华美达广场酒店', '月华路9号', 747, 40, '华美达', '上海', '四钻', '奉贤开发区', '30.814382', '121.464521', 'https://m.tuniucdn.com/fb3/s1/2n9c/45iaCNCuZavJTxwTLskhVKzwynLD_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (56977, '上海五角场华美达大酒店', '黄兴路1888号', 499, 40, '华美达', '上海', '三钻', '江湾/五角场商业区', '31.292932', '121.519759', 'https://m.tuniucdn.com/fb3/s1/2n9c/26VREqAQdaGFvJdAJALVtjxcNMpL_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60214, '上海金茂君悦大酒店', '世纪大道88号(54楼办理入住)', 699, 46, '君悦', '上海', '五星级', '浦东陆家嘴金融贸易区', '31.235152', '121.506082', 'https://m.tuniucdn.com/fb3/s1/2n9c/7Azm3jvGUHuXe3eS1DrixAWVTXY_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60223, '上海希尔顿酒店', '静安华山路250号', 2688, 37, '希尔顿', '上海', '五星级', '静安寺地区', '31.219306', '121.445427', 'https://m.tuniucdn.com/filebroker/cdn/res/92/10/9210e74442aceceaf6e196d61fc3b6b1_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60359, '上海外高桥皇冠假日酒店', '杨高北路1000号', 3299, 46, '皇冠假日', '上海', '五星级', '浦东外高桥地区', '31.338944', '121.590611', 'https://m.tuniucdn.com/fb3/s1/2n9c/VcKUM9zUSiVgDhFioc6mWQoX9ES_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60363, '上海新世界丽笙大酒店', '南京西路88号', 1341, 46, '丽笙', '上海', '五星级', '人民广场地区', '31.23462', '121.47327', 'https://m.tuniucdn.com/fb3/s1/2n9c/2j31b7X3YzGkf4Li3phS6TG1mtwm_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60398, '上海复旦皇冠假日酒店', '邯郸路199号', 924, 47, '皇冠假日', '上海', '五星级', '江湾/五角场商业区', '31.295382', '121.502537', 'https://m.tuniucdn.com/fb3/s1/2n9c/2H1Gk8LHaBWZfYvR6NYYcGTvACmL_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60487, '上海外滩茂悦大酒店', '黄浦路199号', 689, 44, '君悦', '上海', '五星级', '外滩地区', '31.245409', '121.492969', 'https://m.tuniucdn.com/fb3/s1/2n9c/2Swp2h1fdj9zCUKsk63BQvVgKLTo_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60522, '上海嘉豪淮海国际豪生酒店', '汾阳路1号', 425, 45, '豪生', '上海', '四钻', '淮海路/新天地地区', '31.215497', '121.456297', 'https://m.tuniucdn.com/fb3/s1/2n9c/38UBi4QYuaF8jN94CxQ7tb7tjtmZ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60916, '上海绿地万怡酒店', '沪宜公路3101号', 328, 45, '万怡', '上海', '四钻', '嘉定新城', '31.368523', '121.258567', 'https://m.tuniucdn.com/fb3/s1/2n9c/3VLwG9tTQQnp3M3MTeMTdx9nas9B_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60922, '上海虹桥祥源希尔顿酒店', '红松东路1116号', 1108, 45, '希尔顿', '上海', '五钻', '虹桥地区', '31.18746', '121.395312', 'https://m.tuniucdn.com/fb3/s1/2n9c/tQRqDTFkHnHzMZiDKjcGV81ekvc_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (60935, '上海虹口三至喜来登酒店', '四平路59号', 1899, 46, '喜来登', '上海', '五星级', '四川北路商业区', '31.2579', '121.487954', 'https://m.tuniucdn.com/fb3/s1/2n9c/3C3gxLxLjVwnkxJwJm8rd3f38kcd_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (61075, '上海雅居乐万豪酒店', '西藏中路555号', 1152, 46, '万豪', '上海', '五钻', '人民广场地区', '31.236681', '121.473529', 'https://m.tuniucdn.com/fb3/s1/2n9c/3FoT16PkXavKsssvktVvVq5Si6Cr_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (61083, '上海滴水湖皇冠假日酒店', '自由贸易试验区临港新片区南岛1号', 971, 44, '皇冠假日', '上海', '五钻', '滴水湖临港地区', '30.890867', '121.937241', 'https://m.tuniucdn.com/fb3/s1/2n9c/312e971Rnj9qFyR3pPv4bTtpj1hX_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (309208, '北京王府井希尔顿酒店', '王府井东街8号', 1679, 46, '希尔顿', '北京', '五钻', '天安门/王府井地区', '39.914539', '116.413392', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/10/Cii-TF3ePt2IX9UEAALb6VYBSmoAAGKMgGsuW8AAtwB147_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (394559, '北京东方君悦大酒店', '长安街1号东方广场', 686, 45, '君悦', '北京', '五星级', '天安门/王府井地区', '39.909635', '116.414621', 'https://m.tuniucdn.com/fb3/s1/2n9c/3mFqcNSh7eEo9yc3Rw2P5HDNTdDe_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (394617, '北京宝辰饭店', '建国门内大街甲18号', 418, 44, '豪生', '北京', '四星级', '北京站/建国门地区', '39.905768', '116.428153', 'https://m.tuniucdn.com/fb3/s1/2n9c/NEYa6EfDHuhhb19Ct85WBbkKHZU_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (394796, '北京新云南皇冠假日酒店', '东北三环西坝河太阳宫桥东北角云南大厦', 485, 46, '皇冠假日', '北京', '五星级', '国展中心地区', '39.972409', '116.434698', 'https://m.tuniucdn.com/fb3/s1/2n9c/dfP8K782eTsohQWSRdkd7St9LA2_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (395434, '北京希尔顿酒店', '东三环北路东方路1号', 350, 45, '希尔顿', '北京', '五星级', '燕莎/朝阳公园商业区', '39.952703', '116.462387', 'https://m.tuniucdn.com/fb3/s1/2n9c/3fwNbKGhk6XCrkdVyxwhC5uGpLVy_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (395702, '北京首都机场希尔顿酒店', '首都机场3号航站楼三经路1号', 222, 46, '希尔顿', '北京', '五钻', '首都机场/新国展地区', '40.048969', '116.619566', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/10/Cii-U13ePtuIMRSjAAFZ58NGQrMAAGKMgADZ1QAAVn_167_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (395787, '北京海航大厦万豪酒店', '霄云路甲26号', 1302, 46, '万豪', '北京', '五钻', '燕莎/朝阳公园商业区', '39.959861', '116.467363', 'https://m.tuniucdn.com/fb3/s1/2n9c/3zFiWi2C9SmbcQwCZgJFQC9ahvs5_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (395799, '北京国际艺苑皇冠假日酒店', '王府井大街48号', 636, 44, '皇冠假日', '北京', '五星级', '天安门/王府井地区', '39.918994', '116.411277', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/10/Cii-U13ePvyIahjPAAMykV278aEAAGKOQO9e4UAAzKp283_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (395815, '北京明豪华美达酒店', '天竺镇府前一街13号', 558, 46, '华美达', '北京', '四钻', '首都机场/新国展地区', '40.062832', '116.580678', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/13/Cii-U13eP2mIKCwvAAODTZXT-fAAAGKVAA9taIAA4Nl245_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (396189, '北京朝阳悠唐皇冠假日酒店', '三丰北里3号', 944, 46, '皇冠假日', '北京', '五钻', '三里屯/工体/东直门地区', '39.92129', '116.43847', 'https://m.tuniucdn.com/fb3/s1/2n9c/tT6ipLain1ZovR5gnQ7tJ4KKym5_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (396471, '维也纳酒店(北京花园路店)', '海淀北太平庄花园路甲17号', 381, 36, '维也纳', '北京', '三钻', '马甸、安贞地区', '39.970837', '116.365244', 'https://m.tuniucdn.com/filebroker/cdn/res/17/00/1700926908bae6ba3e5ef96de7b7d4cc_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (396506, '北京金隅喜来登酒店', '北三环东路36号', 357, 47, '喜来登', '北京', '五星级', '马甸/安贞地区', '39.967163', '116.4099', 'https://m.tuniucdn.com/fb3/s1/2n9c/29FW2WtGzzUtPhWR1LKxcFZAVa9P_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (413460, '7天连锁酒店(北京天坛店)', '东城天坛东里甲48号', 753, 38, '7天酒店', '北京', '二钻', '前门、崇文门商贸区', '39.875786', '116.421987', 'https://m.tuniucdn.com/fb2/t1/G2/M00/C7/D8/Cii-T1knCK6IWTtxAAI0plLButMAAKYTAJu-woAAjS-422_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (413476, '7天连锁酒店(北京南站店)', '丰台马家堡西路22号', 478, 37, '7天酒店', '北京', '二钻', '永定门、南站、大红门、南苑地区', '39.845363', '116.372327', 'https://m.tuniucdn.com/fb2/t1/G1/M00/26/B7/Cii-U1knCtaISM4VAAHkEQd-mrAAAKw0ALVCwEAAeQp741_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (414168, '7天连锁酒店(北京西直门店)', '西城平安里西大街翠花街育幼胡同甲20-22号', 419, 37, '7天酒店', '北京', '二钻', '西单、金融街地区', '39.931338', '116.364982', 'https://m2.tuniucdn.com/filebroker/cdn/res/bc/66/bc666859edf4fc072a8006c66758058d_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (414481, '7天连锁酒店(北京团结湖地铁站店)', '朝阳团结湖北里9号楼', 525, 36, '7天酒店', '北京', '二钻', '燕莎、三里屯商业区', '39.928457', '116.466132', 'https://m.tuniucdn.com/fb2/t1/G1/M00/38/2D/Cii9EFkv2-uIPTaBAALX6P-rbdUAALPpwHv4ykAAtgA277_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (414698, '7天连锁酒店(北京798艺术区店)', '朝阳北京市朝阳区酒仙桥北路(798艺术区北门)彩虹路6号-电通创意广场大院内', 553, 37, '7天酒店', '北京', '二钻', '望京、酒仙桥、798地区', '39.990671', '116.498452', 'https://m.tuniucdn.com/fb2/t1/G2/M00/D8/11/Cii-T1ku2zqIN7SiAAEdvT6RrjUAAKxZQKFooYAAR3V090_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (415600, '如家酒店(北京朝阳北路传媒大学褡裢坡地铁站店)', '三间房乡褡裢坡村青年沟西侧558号', 259, 47, '如家', '北京', '二钻', '传媒大学/管庄地区', '39.923212', '116.560023', 'https://m.tuniucdn.com/fb3/s1/2n9c/3NezpxNZWQMdNXibwbMkQuAZjDyJ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (415659, '7天连锁酒店(北京紫竹桥店)', '海淀北洼路甲3号', 781, 42, '7天酒店', '北京', '二钻', '西直门及北京展览馆地区', '39.936138', '116.302405', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3C/22/Cii9EVkxPMqIZJz-AAIh0esETAIAALXbgNQkH8AAiHp053_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (416121, '如家酒店(北京西客站北广场店)', '莲花池东路120-2号6层', 275, 43, '如家', '北京', '二钻', '北京西站/丽泽商务区', '39.896449', '116.317382', 'https://m.tuniucdn.com/fb3/s1/2n9c/42DTRnKbiYoiGFVzrV9ZJUxNbvRo_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (416260, '7天连锁酒店(北京通州八里桥店)', '永顺镇西马庄小区', 534, 38, '7天酒店', '北京', '二钻', '果园环岛、通州区', '39.915443', '116.631871', 'https://m.tuniucdn.com/fb2/t1/G2/M00/DF/5A/Cii-TlkxkeGIKM0oAAGOb64RvToAALBAAH9Fg8AAY6H201_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (416268, '和颐酒店(北京传媒大学财满街店)', '朝阳路高井176号', 524, 46, '和颐', '北京', '三钻', '国贸地区', '39.918277', '116.53015', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/13/Cii-TF3eP5GIJIOLAAUwsIVCxdAAAGKXgK5a0IABTDI239_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (416307, '速8酒店(北京新国展首都机场后沙峪店)', '后沙峪镇裕民大街32号', 350, 39, '速8', '北京', '二钻', '首都机场/新国展地区', '40.099019', '116.543655', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/3E/Cii-TF3eRgGIHCkKAAP_ATvriiQAAGL0AIoLtUAA_8Z513_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (432335, '7天连锁酒店(上海北外滩国际客运中心地铁站店)', '唐山路145号', 249, 35, '7天酒店', '上海', '二钻', '北外滩地区', '31.252585', '121.498753', 'https://m2.tuniucdn.com/filebroker/cdn/res/c1/ba/c1baf64418437c56617f89840c6411ef_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (433576, '如家酒店(上海南京路步行街店)', '南京东路480号保安坊内', 379, 44, '如家', '上海', '二钻', '人民广场地区', '31.236454', '121.480948', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/BA/Cii-U13eXVaIQmdaAAWxgzdXXxEAAGRrgNIOkoABbGb143_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (434082, '如家酒店·neo(上海外滩城隍庙小南门地铁站店)', '复兴东路260号', 392, 44, '如家', '上海', '二钻', '豫园地区', '31.220706', '121.498769', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/B6/Cii-U13eXLGIdHFzAAIG-5cEwDEAAGRfQNNIV0AAgcT627_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (441836, '如家酒店(北京国展三元桥店)', '西坝河东里36号', 458, 47, '如家', '北京', '二钻', '国展中心地区', '39.966238', '116.450142', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/39/Cii-TF3eRTGITp1UAAYIilRD7skAAGLngIuAnQABgii479_w200_h200_c1_t0.png'); INSERT INTO `hotel` VALUES (485775, '如家酒店(上海闵行华东师范大学吴泾店)', '吴泾镇宝秀路977号', 161, 45, '如家', '上海', '二钻', '交大/闵行经济开发区', '31.047135', '121.46224', 'https://m.tuniucdn.com/fb3/s1/2n9c/V8pz15CkiMX5xYJRmbbp5zkKWJ8_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (489756, '7天连锁酒店(北京平谷店)', '文化北街4-16号', 544, 40, '7天酒店', '北京', '二钻', '平谷城区', '40.14308', '117.111554', 'https://m2.tuniucdn.com/filebroker/cdn/res/2e/b4/2eb4edb22ddb981307d8570beb1d746d_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (517915, '如家酒店·neo(深圳草埔地铁站店)', '布吉路1036号', 159, 44, '如家', '深圳', '二钻', '田贝/水贝珠宝城', '22.583191', '114.118499', 'https://m.tuniucdn.com/fb3/s1/2n9c/228vhBCQmFRFWQBYX1cgoFQb6x58_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (527938, '深圳好日子皇冠假日酒店', '福华一路28号', 590, 46, '皇冠假日', '深圳', '五星级', '会展中心/CBD', '22.537153', '114.053529', 'https://m.tuniucdn.com/fb3/s1/2n9c/b6Ztz5jn4MngK3Hzfxuu9JGsjrm_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (541619, '如家酒店(上海莘庄地铁站龙之梦商业广场店)', '莘庄镇莘浜路172号', 149, 44, '如家', '上海', '二钻', '莘庄工业区', '31.105797', '121.37755', 'https://m.tuniucdn.com/fb3/s1/2n9c/3mKs3jETvJDj3dDdkRB9UyLLvPna_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (542068, '上海茂业华美达广场酒店', '沪南路938号', 646, 40, '华美达', '上海', '三钻', '浦东新国际博览中心', '31.182761', '121.554106', 'https://m.tuniucdn.com/fb3/s1/2n9c/2139uDFUZ2VKxrathwSeeE4DwyFU_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (546869, '深圳彭年万丽酒店', '嘉宾路2002号(毗邻金光华购物广场)', 701, 46, '万丽', '深圳', '五钻', '罗湖口岸/火车站', '22.540989', '114.122665', 'https://m.tuniucdn.com/fb3/s1/2n9c/gwAbqEXFUpjUBmnxUfK89p3zBBT_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (581859, '维也纳酒店(北京丰益桥店)(原申晨酒店)', '丰台丰管路8号', 648, 45, '维也纳', '北京', '三钻', '北京西站、丽泽商务区', '39.857707', '116.312482', 'https://m2.tuniucdn.com/filebroker/cdn/res/97/43/97438481b9e79abad429e5c30d7f303f_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (584697, '7天连锁酒店(深圳华强赛格广场店)', '华强南路3024号赛格苑1栋', 362, 36, '7天酒店', '深圳', '二钻', '华强北商业区', '22.539831', '114.087899', 'https://m.tuniucdn.com/fb2/t1/G2/M00/D8/11/Cii-T1ku2zmIcP4sAAEw8iuLXFgAAKxZQH7HVYAATEK972_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (593228, '7天连锁酒店(北京颐和园店)', '海淀厢红旗路功德寺桥北侧', 730, 38, '7天酒店', '北京', '二钻', '香山、八大处风景区', '40.003959', '116.256718', 'https://m2.tuniucdn.com/filebroker/cdn/res/55/84/55841f502c5a711e66dd5454b64f559b_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (598591, '上海丽昂豪生大酒店', '金新路99号', 529, 47, '豪生', '上海', '四钻', '浦东金桥地区', '31.252496', '121.600085', 'https://m.tuniucdn.com/fb3/s1/2n9c/2KfPPyPx9rWyVXif2CUuxv61Nryc_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (607915, '汉庭酒店(深圳皇岗店)', '滨河大道6033号海滨广场国皇大厦3楼', 313, 42, '汉庭', '深圳', '二钻', '皇岗口岸/福田口岸', '22.528101', '114.064221', 'https://m.tuniucdn.com/fb3/s1/2n9c/qMyCJVYuW21nsCeEBt8CMfmEhra_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (608374, '如家酒店(上海浦东机场龙东大道合庆店)', '东川公路5863号', 160, 45, '如家', '上海', '二钻', '浦东机场核心区', '31.237662', '121.718556', 'https://m.tuniucdn.com/fb3/s1/2n9c/LUYxGGV4pzjKeN5a69K4deU8JD8_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (609023, '如家酒店·neo(上海外高桥保税区北地铁站店)', '花山路1209号', 266, 45, '如家', '上海', '二钻', '浦东外高桥地区', '31.351148', '121.585606', 'https://m.tuniucdn.com/fb3/s1/2n9c/3cJ6KTfms9cfEnME8WRkQQBXBkYm_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (609372, '豪派特华美达广场酒店(深圳北站店)', '民治街道梅龙路与民旺路交汇处', 498, 45, '华美达', '深圳', '四钻', '深圳北站地区', '22.620501', '114.033874', 'https://m.tuniucdn.com/fb3/s1/2n9c/3G5TnUCPbjGYHAVWfvuixw8bs69t_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (624417, '深圳君悦酒店', '宝安南路1881号', 442, 47, '君悦', '深圳', '五钻', '万象城/京基100', '22.537247', '114.111182', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EA/Cii-TF3ZpVmIVDJ9AAXvJftz_AgAAFrrQKbI4oABe89086_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (628327, '如家酒店·neo(深圳罗湖口岸国贸地铁站店)', '人民南路2011号', 223, 45, '如家', '深圳', '二钻', '罗湖口岸/火车站', '22.536734', '114.118336', 'https://m.tuniucdn.com/fb3/s1/2n9c/2rKHmQWHYiY8GZA3xBHpFKCLZwZo_w200_h200_c1_t0.png'); INSERT INTO `hotel` VALUES (629023, '和颐酒店(北京十里河欢乐谷店)', '十八里店乡周家庄288号', 390, 47, '和颐', '北京', '四钻', '劲松/潘家园地区', '39.853354', '116.483437', 'https://m.tuniucdn.com/fb3/s1/2n9c/28hnDdqn5uzuzCKYkw2x4pYmunXM_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (629729, '7天连锁酒店(上海张江高科园区店)', '浦东新区蔡伦路103号', 267, 36, '7天酒店', '上海', '二钻', '浦东张江地区', '31.196154', '121.62071', 'https://m2.tuniucdn.com/filebroker/cdn/res/d9/61/d961508a10865b9b29c033064f31b913_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (635963, '深圳龙岗珠江皇冠假日酒店', '龙岗中心城龙翔大道9009号珠江广场', 737, 46, '皇冠假日', '深圳', '五星级', '龙岗中心区/大运新城', '22.722941', '114.250002', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EA/Cii-U13ZpWGIasKjAAY1SNE36KMAAFrrwMNoAwABjVg973_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (636080, '深圳大中华喜来登酒店', '福华路一号大中华国际交易广场', 1556, 47, '喜来登', '深圳', '五星级', '会展中心/CBD', '22.535567', '114.062005', 'https://m.tuniucdn.com/fb3/s1/2n9c/3hQRTmAUW9PegTjxMiEfYwh2HnKp_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (644417, '上海外高桥喜来登酒店', '自由贸易试验区基隆路28号(二号门内)', 2419, 46, '喜来登', '上海', '五钻', '浦东外高桥地区', '31.350989', '121.588751', 'https://m.tuniucdn.com/fb3/s1/2n9c/1Rrtg9n7PdMEivVDhsehbJBrEre_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (648219, '上海金桥红枫万豪酒店', '新金桥路15号', 891, 47, '万豪', '上海', '五钻', '浦东金桥地区', '31.244061', '121.591153', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/B6/Cii-TF3eXKuIR_a0AAUx-Xd2JLQAAGRfACSpvUABTIR560_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (657192, '深圳宝安中天美景华美达酒店', '新桥街道万丰社区中心路7-1号', 498, 45, '华美达', '深圳', '四钻', '深圳国际会展中心商圈', '22.716473', '113.826391', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EA/Cii-U13ZpVeIRbhTAAOzGZSDtlcAAFrrQEWM-AAA7Mx626_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (659496, '维也纳酒店(深圳国王店)', '龙华新区龙华龙观西路95号', 714, 37, '维也纳', '深圳', '三钻', '深圳北站地区', '22.65892', '114.006817', 'https://m2.tuniucdn.com/filebroker/cdn/res/b4/76/b476cacc575a7ff237128ba2fd63923a_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (670673, '北京龙城华美达酒店', '昌平路319号', 506, 45, '华美达', '北京', '四钻', '回龙观/天通苑地区', '40.084219', '116.304313', 'https://m.tuniucdn.com/fb3/s1/2n9c/T3WruZV3S4MfcxdD1HFVhZjaBLW_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (672207, '和颐至尊酒店(北京望京798店)', '酒仙桥北路9号荧屏里4号楼', 579, 44, '和颐', '北京', '四钻', '望京/酒仙桥/798地区', '39.98835', '116.491217', 'https://m.tuniucdn.com/fb3/s1/2n9c/2y56zwK8kd2tBuRUyF7XeJ2ucvWM_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (684720, '和颐酒店(深圳罗湖口岸火车地铁站店)', '沿河南路1064号', 208, 47, '和颐', '深圳', '四钻', '罗湖口岸/火车站', '22.533753', '114.122491', 'https://m.tuniucdn.com/fb3/s1/2n9c/2LFgB2iFawKKoGADwzhW6jpCSaJT_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (696948, '上海新园华美达广场酒店', '漕宝路509号', 1290, 45, '华美达', '上海', '四星级', '光大会展中心/漕河泾地区', '31.163802', '121.405618', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/B6/Cii-TF3eXHuIE57sAAZx8iP6rMIAAGRbgAH09gABnIK621_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (706343, '速8酒店(北京西客站北广场店)', '丰台莲花池东路126号', 268, 39, '速8', '北京', '二钻', '北京西站、丽泽商务区', '39.896623', '116.315586', 'https://m.tuniucdn.com/fb2/t1/G2/M00/E3/46/Cii-TlkzMXWIL0sAAAGG8a3YwiwAALJlgG-r5YAAYcJ067_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (707357, '维也纳酒店(上海南站光大店)', '徐汇桂林路46号(钦州南路路口往南100米)', 3288, 36, '维也纳', '上海', '三钻', '光大会展中心', '31.156297', '121.419948', 'https://m2.tuniucdn.com/filebroker/cdn/res/f7/13/f713f8f98d777d8d53aafefb37a79ef6_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (711837, '速8酒店(北京立水桥店)', '朝阳安立路3号1幢3层', 268, 36, '速8', '北京', '二钻', '亚运村、奥体中心地区', '40.043717', '116.410962', 'https://m2.tuniucdn.com/filebroker/cdn/res/b3/87/b3876eaf16af62521cf6fb474504b8ca_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (727679, '7天连锁酒店(深圳步行街老街地铁站二店)', '罗湖区东门中路2216号华佳广场12-14楼(东门天桥东头)', 742, 40, '7天酒店', '深圳', '二钻', '东门商业区', '22.54585', '114.122227', 'https://m.tuniucdn.com/fb2/t1/G1/M00/39/99/Cii9EFkwVMKIP_mCAAI3fOHlS1wAALSDAMeO2MAAjeU309_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (728180, '如家酒店(深圳宝安西乡地铁站店)', '西乡大道298-7号(富通城二期公交站旁)', 184, 43, '如家', '深圳', '二钻', '宝安体育中心商圈', '22.569693', '113.860186', 'https://m.tuniucdn.com/fb3/s1/2n9c/FHdugqgUgYLPMoC4u4rdTbAPrVF_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (728415, '如家酒店·neo(深圳东门步行街晒布地铁站店)', '晒布路67号', 152, 46, '如家', '深圳', '二钻', '东门商业区', '22.550183', '114.120771', 'https://m.tuniucdn.com/fb2/t1/G6/M00/25/57/Cii-U13PFNWISSnQAAEpTtoilsQAAEVWgEvur8AASlm647_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (728461, '汉庭酒店(深圳会展中心店)', '新洲路世纪工艺品广场307栋', 258, 44, '汉庭', '深圳', '二钻', '皇岗口岸/福田口岸', '22.518026', '114.046061', 'https://m.tuniucdn.com/fb2/t1/G6/M00/25/56/Cii-TF3PFKOIPl0JAANm4ge6DdMAAEVTQK2SP8AA2b6365_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (728604, '如家酒店·neo(深圳南山地铁站南山市场店)', '南新路顺富街18号化州大厦', 198, 43, '如家', '深圳', '二钻', '科技园', '22.525561', '113.920058', 'https://m.tuniucdn.com/fb2/t1/G6/M00/25/57/Cii-TF3PFLmIDGWiAAPHkaNTuOIAAEVVQBGazAAA8ep611_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (730454, '7天连锁酒店(深圳万象城店)', '罗湖区嘉宾路4025号城市天地广场内', 552, 43, '7天酒店', '深圳', '二钻', '罗湖口岸/火车站', '22.537078', '114.113733', 'https://m.tuniucdn.com/fb2/t1/G2/M00/C8/4C/Cii-Tlknhz2IFnYNAAInF2jEK14AAKbcQNB5M8AAicv660_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (730569, '7天连锁酒店(深圳梅林卓越城店)', '孖岭地铁口C出口左手边,青年学院对面', 269, 39, '7天酒店', '深圳', '二钻', '莲花山/梅林', '22.568701', '114.068464', 'https://m.tuniucdn.com/fb2/t1/G2/M00/D8/0B/Cii-Tlku2dOISeGXAAAUw3MvPrIAAKxYALB2VAAABTb555_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (730968, '7天连锁酒店(深圳宝安地铁站店)', '宝安区宝安25区创业二路步行街金麒麟服装广场4栋', 314, 36, '7天酒店', '深圳', '二钻', '宝安中心区/前海', '22.568162', '113.900968', 'https://m.tuniucdn.com/fb2/t1/G2/M00/D8/0B/Cii-T1ku2cqIWTOOAAAS_bvRI5UAAKxXwILCFYAABMV285_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (751035, '7天连锁酒店(上海自贸区北门地铁站店)(原外高桥地铁北站店)', '花山路706号', 328, 39, '7天酒店', '上海', '二钻', '浦东外高桥地区', '31.348029', '121.576896', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3A/21/Cii-U1kwxUCINXaHAAGmh7z6qRAAALUdwMKGREAAaaf928_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (844350, '7天连锁酒店(深圳世界之窗店)', '南山区白石洲沙河街2号金三角大厦', 769, 36, '7天酒店', '深圳', '二钻', '华侨城', '22.540501', '113.968858', 'https://m.tuniucdn.com/fb2/t1/G2/M00/D8/11/Cii-TFku2zmIOdjCAAAQJpLFhEEAAKxZQIEvQ0AABA-920_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2316304, '如家酒店(深圳双龙地铁站店)', '龙岗街道龙岗墟社区龙平东路62号', 135, 45, '如家', '深圳', '二钻', '龙岗中心区/大运新城', '22.730828', '114.278337', 'https://m.tuniucdn.com/fb3/s1/2n9c/4AzEoQ44awd1D2g95a6XDtJf3dkw_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2329005, '维也纳酒店(深圳华之沙店)', '福强路新洲九街28号', 651, 39, '维也纳', '深圳', '三钻', '皇岗口岸/福田口岸', '22.524835', '114.048214', 'https://m2.tuniucdn.com/filebroker/cdn/res/88/f0/88f05cd11990ef39ae187886c76f40a5_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2351601, '深圳蛇口希尔顿南海酒店', '望海路1177号', 509, 47, '希尔顿', '深圳', '五钻', '深圳湾口岸/蛇口', '22.479373', '113.916013', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EA/Cii-TF3ZpXOIfa6fAAJjiUOiuYgAAFrtgDtgpQAAmOh799_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2359697, '如家酒店(北京上地安宁庄东路店)', '清河小营安宁庄东路18号20号楼', 420, 46, '如家', '北京', '二钻', '上地产业园/西三旗', '40.041322', '116.333316', 'https://m.tuniucdn.com/fb3/s1/2n9c/2wj2f8mo9WZQCmzm51cwkZ9zvyp8_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (5865979, '北京丽都皇冠假日酒店', '将台路6号', 1168, 47, '皇冠假日', '北京', '五钻', '望京/酒仙桥/798地区', '39.978133', '116.478642', 'https://m.tuniucdn.com/fb3/s1/2n9c/Yo4xL3RUsYUnDDc5QcQWj7sCrUX_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (5870456, '上海宝华万豪酒店', '广中西路333号', 922, 47, '万豪', '上海', '五钻', '大宁国际商业区', '31.279371', '121.446327', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/BA/Cii-U13eXVqIZXDFAAUC_xbrQDAAAGRrwPRyOcABQMX057_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (5871652, '上海圣诺亚皇冠假日酒店', '金沙江路1699号', 770, 46, '皇冠假日', '上海', '五钻', '长风公园地区', '31.232346', '121.377709', 'https://m.tuniucdn.com/fb3/s1/2n9c/J4sP7qRSHa9rFYnKTW75ZPB393M_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (5872067, '崇明金茂凯悦酒店', '陈家镇揽海路799弄', 1024, 46, '凯悦', '上海', '五钻', '崇明岛/长兴岛/横沙岛', '31.466563', '121.799671', 'https://m.tuniucdn.com/fb3/s1/2n9c/fsKrbnNsmSsYnNLmhh3ZvVjZ5cA_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (5873072, '速8酒店(上海火车站北广场店)', '闸北芷江西路796号', 190, 41, '速8', '上海', '二钻', '上海火车站地区', '31.255579', '121.452903', 'https://m2.tuniucdn.com/filebroker/cdn/res/96/6d/966d6596e6cb7b48c9cc1d7da79b57c8_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (7094829, '汉庭酒店(深圳华强南店)', '松岭路9号(南园小学对面)', 215, 40, '汉庭', '深圳', '二钻', '华强北商业区', '22.536842', '114.094316', 'https://m.tuniucdn.com/fb3/s1/2n9c/3WDhaZZ9yALHw8yNiU6HJyrdC3u5_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (189429168, '7天连锁酒店(北京大兴黄村清源路地铁站店)', '清源西路55号', 392, 38, '7天酒店', '北京', '二钻', '大兴农业生态观光区', '39.743751', '116.321676', 'https://m.tuniucdn.com/fb2/t1/G1/M00/4F/25/Cii9EFk3LmOIFtnDAAHm5kdIiM8AAL1FQM8kG0AAeb-418_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197487869, '如家酒店(北京第二外国语大学南门双桥地铁站店)', '三间房乡新房村1号', 321, 47, '如家', '北京', '二钻', '传媒大学/管庄地区', '39.90635', '116.565528', 'https://m.tuniucdn.com/fb3/s1/2n9c/ZkgDAs8tTMvgFHdVPpikNqENEn1_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197488318, '速8酒店(北京立水桥地铁南站店)', '朝阳北苑路18号院3号楼4层', 344, 36, '速8', '北京', '二钻', '亚运村、奥体中心地区', '40.043689', '116.414138', 'https://m.tuniucdn.com/fb2/t1/G1/M00/36/4D/Cii9EVkvP72IYYjgAAF7yZeWV-wAALMQACOARMAAXvh983_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197492277, '速8酒店(北京平谷兴谷环岛店)', '平谷平谷大街31号', 614, 39, '速8', '北京', '二钻', '平谷城区', '40.159255', '117.12401', 'https://m.tuniucdn.com/fb2/t1/G1/M00/38/D5/Cii9EFkwFCiII79zAAHKsXy_LAoAALQuQEmEZ4AAcrJ339_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197492479, '如家酒店(北京顺义中心地铁站店)', '光明南大街14号', 306, 45, '如家', '北京', '二钻', '顺义温泉休闲区', '40.124783', '116.65751', 'https://m.tuniucdn.com/fb3/s1/2n9c/2hNBSjmMTk6JQ2o8ixr5s3ioevhB_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197496182, '和颐酒店(北京团结湖地铁站店)', '团结湖路9号楼', 341, 44, '和颐', '北京', '三钻', '燕莎/朝阳公园商业区', '39.930731', '116.466602', 'https://m.tuniucdn.com/fb3/s1/2n9c/2gK41VpMb4AwyNkwQEkfFo83uTUU_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197496980, '速8酒店(北京温都水城王府店)', '昌平北七家镇平西府村(温都水城东200米)', 585, 39, '速8', '北京', '二钻', '小汤山温泉度假区', '40.10144', '116.380641', 'https://m.tuniucdn.com/fb2/t1/G2/M00/C7/CB/Cii-T1km_5eICnpJAAHOWN1GylMAAKYJwF0Hp8AAc5w000_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197516492, '速8酒店(北京南苑东高地店)', '丰台南大红门路东营房15号', 651, 39, '速8', '北京', '二钻', '永定门、南站、大红门、南苑地区', '39.78996', '116.42081', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3B/D8/Cii-U1kxKGWIQlaxAAIdkjkSALkAALXDQMFbTsAAh2q158_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197835483, '7天连锁酒店(深圳大学桃园店)', '南山区桃园西路160号', 431, 36, '7天酒店', '深圳', '二钻', '科技园', '22.532576', '113.916362', 'https://m.tuniucdn.com/fb2/t1/G1/M00/38/40/Cii9EFkv4XKIQN85AAFUcDrkXe0AALPvwPRn08AAVSI037_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (197837109, '如家酒店·neo(深圳龙岗大道布吉地铁站店)', '布吉镇深惠路龙珠商城', 127, 43, '如家', '深圳', '二钻', '布吉/深圳东站', '22.602482', '114.123284', 'https://m.tuniucdn.com/fb2/t1/G6/M00/25/58/Cii-TF3PFZOIA7jwAAKInGFN4xgAAEVbAGeP4AAAoi0485_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (198323591, '汉庭酒店(深圳北站龙华汽车站店)', '龙华新区建辉路2号', 209, 46, '汉庭', '深圳', '二钻', '深圳北站地区', '22.671313', '114.02784', 'https://m.tuniucdn.com/fb3/s1/2n9c/2dkB2HzbaBUJ7adZZfZaeS9JCvjP_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200208940, '上海浦东喜来登由由公寓', '浦建路38号', 3168, 45, '喜来登', '上海', '五钻', '浦东新国际博览中心', '31.208553', '121.518552', 'https://m.tuniucdn.com/fb3/s1/2n9c/m3Nrm37Yx6YV4NwqRvSYnFRNSGk_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200210163, '7天连锁酒店(上海徐家汇宜山路地铁站店)', '徐汇钦州北路78号', 219, 35, '7天酒店', '上海', '二钻', '光大会展中心', '31.180615', '121.422916', 'https://m.tuniucdn.com/fb2/t1/G2/M00/DF/96/Cii-Tlkx0TOIGtOzAAEe_xcDxeIAALCZQJyxf4AAR8X941_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200214437, '上海浦东机场华美达广场酒店', '浦东机场启航路1100号', 600, 45, '华美达', '上海', '四星级', '浦东机场核心区', '31.160969', '121.799086', 'https://m.tuniucdn.com/fb3/s1/2n9c/2D2gbXDgrMx76uWfwzmoWpmSCCXx_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200214538, '上海绿地万豪酒店', '江滨路99号(打浦路底)', 720, 43, '万豪', '上海', '五星级', '打浦桥地区', '31.192103', '121.47298', 'https://m.tuniucdn.com/fb3/s1/2n9c/268jVMuWdYok5ehGFhQ2QNhBhUhs_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200214715, '上海浦东喜来登由由大酒店', '浦建路38号', 2489, 45, '喜来登', '上海', '五星级', '浦东新国际博览中心', '31.208739', '121.518305', 'https://m.tuniucdn.com/fb3/s1/2n9c/36t2KUGs4h5YgYSaLSkr5pMXLM54_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200214824, '7天连锁酒店(上海陆家嘴八佰伴店)', '崂山路689号', 249, 36, '7天酒店', '上海', '二钻', '浦东陆家嘴金融贸易区', '31.220656', '121.525127', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3D/95/Cii9EVkx0JCIRDFfAAIMnl8npiYAALaawHMG2kAAgy2536_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200215226, '上海颖奕皇冠假日酒店', '博园路6555号', 907, 45, '皇冠假日', '上海', '五钻', '嘉定新城', '31.272533', '121.19179', 'https://m.tuniucdn.com/fb3/s1/2n9c/3Uyfi2aBRETE1K5PChiLVZCwtDLF_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200215286, '上海万豪虹桥大酒店', '虹桥路2270号', 910, 46, '万豪', '上海', '五星级', '虹桥地区', '31.191529', '121.375577', 'https://m.tuniucdn.com/fb2/t1/G6/M00/52/B6/Cii-TF3eXK6IBQoRAAbgs1dyxJwAAGRfAPXbPQABuDL314_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200215365, '如家酒店(上海虹桥漕河泾古北店)', '虹梅路2971号', 189, 44, '如家', '上海', '二钻', '虹桥地区', '31.180968', '121.392415', 'https://m.tuniucdn.com/fb3/s1/2n9c/2WPfVp6auQkYoHzAdSbxwHAtQFfa_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200215548, '速8酒店(上海虹桥枢纽九亭中心路店)', '松江九亭镇中心路128号', 198, 39, '速8', '上海', '二钻', '七宝古镇', '31.119363', '121.322768', 'https://m.tuniucdn.com/fb2/t1/G1/M00/42/40/Cii-U1kziVOIGTw-AAGRMfcIwJwAALi6ACRnUsAAZFJ536_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (200216665, '维也纳酒店(上海奉贤南桥中心店)', '奉贤沪杭公路1758-8号', 1289, 38, '维也纳', '上海', '三钻', '奉贤开发区', '30.934646', '121.451449', 'https://m.tuniucdn.com/fb2/t1/G2/M00/DC/A8/Cii-T1kw5leIQAA3AAFzNYtL4loAAK9OQOyk4sAAXNN152_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (219484323, '7天连锁酒店(深圳观澜章阁店)', '宝安区章阁村桂月路章阁市场汇龙峰景一期A栋2-4层', 725, 40, '7天酒店', '深圳', '二钻', '观澜', '22.746493', '114.023', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3C/8C/Cii-U1kxXqaIeqeuAAHwF4GDmOcAALYFQI9zMMAAfAv100_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (223318960, '和颐酒店(深圳深南大道华强路地铁站店)', '深南中路2081号', 637, 46, '和颐', '深圳', '四钻', '华强北商业区', '22.540313', '114.088611', 'https://m.tuniucdn.com/fb3/s1/2n9c/2M7am7D8rPTeTQAhxqBeMSANaqGr_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (233036941, '7天连锁酒店(上海东林寺店)', '朱泾镇文商路79号', 218, 37, '7天酒店', '上海', '二钻', '金山枫泾古镇地区', '30.895912', '121.160238', 'https://m.tuniucdn.com/fb2/t1/G4/M00/35/13/Cii_J1zr5PyIY3acAAFCnHJPxLUAAGX-ABvcIMAAUK0087_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (234719711, '如家酒店·neo(北京朝阳北路十里堡地铁站店)', '朝阳北路八里庄南里26号', 378, 47, '如家', '北京', '二钻', '国贸地区', '39.922472', '116.501118', 'https://m.tuniucdn.com/fb3/s1/2n9c/2rHdXNCmycnUxw99AniFC25ZDSfJ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (234719728, '速8酒店(北京房山城关店)', '房山城关镇城隍庙街10号(原房山老公安局)', 392, 47, '速8', '北京', '二钻', '', '39.705216', '115.981904', 'https://m.tuniucdn.com/fb2/t1/G1/M00/3F/66/Cii9EFkyeImIB3ZVAAHcTtTFt4oAALdsgICDO0AAdxm378_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (235196477, '和颐酒店(北京总部基地店)', '丰葆路106号', 379, 45, '和颐', '北京', '四钻', '总部基地/丰台体育中心/南宫地区', '39.815383', '116.291012', 'https://m.tuniucdn.com/fb3/s1/2n9c/3J7Hcvwt5xZJL3NkS4wPJ6csmFb9_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (339777429, '上海嘉定喜来登酒店', '菊园新区嘉唐公路66号', 1286, 44, '喜来登', '上海', '五钻', '嘉定新城', '31.394595', '121.245773', 'https://m.tuniucdn.com/fb3/s1/2n9c/2v2fKuo5bzhunSBC1n1E42cLTkZV_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (339952837, '如家酒店(北京良乡西路店)', '良乡西路7号', 159, 46, '如家', '北京', '二钻', '房山风景区', '39.73167', '116.132482', 'https://m.tuniucdn.com/fb3/s1/2n9c/3Dpgf5RTTzrxpeN5y3RLnRVtxMEA_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (343341695, '和颐酒店(北京中关村软件园店)', '东北旺西路8号中关村软件园一期9号楼', 245, 47, '和颐', '北京', '四钻', '上地产业园/西三旗', '40.044663', '116.29607', 'https://m.tuniucdn.com/fb3/s1/2n9c/3hSkPeWRQ3VK1heRQpHzJNMTanQz_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (365011120, '和颐酒店(北京石景山万达广场店)', '鲁谷东街甲26号', 505, 47, '和颐', '北京', '四钻', '公主坟/五棵松/石景山游乐园地区', '39.895479', '116.240386', 'https://m.tuniucdn.com/fb3/s1/2n9c/3iwohdQzyZP9azUkYAwTFj7WzBwd_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (368343863, '如家酒店(上海金桥博兴路地铁站店)', '博兴路1119号', 218, 45, '如家', '上海', '二钻', '浦东金桥地区', '31.266272', '121.593829', 'https://m.tuniucdn.com/fb3/s1/2n9c/w5ERtGJEmdgdgy5qtLPatR1xfm4_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (368701368, '深圳大中华希尔顿酒店', '福田深南大道1003号', 1666, 46, '希尔顿', '深圳', '五钻', '会展中心/CBD', '22.539313', '114.069763', 'https://m.tuniucdn.com/fb3/s1/2n9c/4EnHseZ73LXdFJY7DSdJ8xqAcjXe_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1393017952, '汉庭酒店(深圳宝安松岗地铁站店)', '松岗镇河滨北路12号盛华大厦', 166, 47, '汉庭', '深圳', '二钻', '松岗商业中心区', '22.768912', '113.83325', 'https://m.tuniucdn.com/fb3/s1/2n9c/4NehRjdHyZDKxTjAxTYv27FHq8LJ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1400304687, '如家酒店(深圳横岗地铁站新马商贸城店)', '龙岗大道横岗段4004号', 149, 43, '如家', '深圳', '二钻', '龙岗中心区/大运新城', '22.642629', '114.202799', 'https://m.tuniucdn.com/fb2/t1/G6/M00/25/5A/Cii-TF3PFkiIb27dAAEqdDcKl3YAAEViQGVWY0AASqM960_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1406627919, '深圳中洲万豪酒店', '海德一道88号中洲控股中心A座', 204, 47, '万豪', '深圳', '五钻', '海岸城/后海', '22.517293', '113.933785', 'https://m.tuniucdn.com/fb3/s1/2n9c/3wsinQAcuWtCdmv1yxauVG2PSYpC_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1418471719, '上海宝龙丽笙酒店', '金海路2449弄2号', 860, 46, '丽笙', '上海', '五钻', '浦东金桥地区', '31.26571', '121.650132', 'https://m.tuniucdn.com/fb3/s1/2n9c/3myGUurFCriEVMGPy9yYMPFdb9Zh_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1455383931, '如家酒店(深圳宝安客运中心站店)', '西乡河西金雅新苑34栋', 169, 45, '如家', '深圳', '二钻', '宝安商业区', '22.590272', '113.881933', 'https://m.tuniucdn.com/fb3/s1/2n9c/2w9cbbpzjjsyd2wRhFrnUpBMT8b4_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1457521002, '7天连锁酒店(深圳西丽茶光地铁站店)', '珠光北路280号天下湘军1楼', 517, 39, '7天酒店', '深圳', '二钻', '大学城/西丽动物园', '22.576187', '113.956166', 'https://m.tuniucdn.com/fb2/t1/G2/M00/E3/E0/Cii-Tlkzdl6IfQYfAAHCgNVDe1sAALK6gPBDhQAAcKY242_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1463484295, '上海和平豪生酒店', '沪南公路2653-2号', 650, 41, '豪生', '上海', '四钻', '周浦康桥地区', '31.146478', '121.568218', 'https://m.tuniucdn.com/fb3/s1/2n9c/ZxM9gWHqj657ndRsHw4j4p3CQ5k_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1514269829, '如家酒店(上海东川路碧江商业广场店)', '东川路2645号', 218, 45, '如家', '上海', '二钻', '交大/闵行经济开发区', '31.008875', '121.402813', 'https://m.tuniucdn.com/fb3/s1/2n9c/R92UunuCRXiG826G9Ptu7orqs7b_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1557882030, '维也纳酒店(深圳东门老街店)', '罗湖区东门新园路37号益德楼', 336, 43, '维也纳', '深圳', '三钻', '东门商业区', '22.549413', '114.118866', 'https://m.tuniucdn.com/fb2/t1/G1/M00/45/83/Cii9EFk0opCIPl9CAAKHl3Egm6oAALoKwLNWlwAAoev470_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1557997004, '上海五角场凯悦酒店', '国定东路88号', 1104, 46, '凯悦', '上海', '五钻', '江湾/五角场商业区', '31.300645', '121.51918', 'https://m.tuniucdn.com/fb3/s1/2n9c/3a3Zz9cDgbJEEJ1GcXzKhTh21YqK_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1565094427, '上海国际旅游度假区万怡酒店', '秀浦路3999弄17号', 713, 45, '万怡', '上海', '四钻', '迪士尼度假区', '31.132913', '121.63464', 'https://m.tuniucdn.com/fb3/s1/2n9c/KPBUPunPDETYWg8WaJDSmiZC65z_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1584362548, '如家酒店(上海浦东国际旅游度假区御桥地铁站店)', '御青路315-317号', 339, 44, '如家', '上海', '二钻', '周浦康桥地区', '31.15719', '121.572392', 'https://m.tuniucdn.com/fb3/s1/2n9c/2ybd3wqdoBtBeKcPxmyso9y1hNXa_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1630005459, '7天连锁酒店(深圳地王大厦红桂路店)(原红桂路店)', '罗湖区宝安南路2078号深港豪苑(与红桂路交汇处)', 143, 39, '7天酒店', '深圳', '二钻', '', '22.550341', '114.10965', 'https://m.tuniucdn.com/fb2/t1/G2/M00/EA/18/Cii-T1k1KaGIIkQVAAD4fD_T3FcAALTtABiCJ8AAPiU164_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1637944903, '速8酒店北京后海店', '西城北京市西城区德胜门内大街兴华胡同五福里2号', 213, 39, '速8', '北京', '二钻', '后海', '39.934452', '116.38184', 'https://m.tuniucdn.com/fb2/t1/G1/M00/48/0C/Cii9EVk1JNuILdBWAAHv5O89TjMAALrFgJ8bwcAAe_8197_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1649956165, '上海南青华美达酒店', '华夏东路811号', 299, 47, '华美达', '上海', '四钻', '迪士尼度假区', '31.195206', '121.664791', 'https://m.tuniucdn.com/fb3/s1/2n9c/2RHmQgTpte3UVSDJ5KbqobbZGRnE_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1714520967, '速8酒店(北京安华桥黄寺大街店)', '黄寺大街12号院16号楼', 559, 43, '速8', '北京', '二钻', '马甸、安贞地区', '39.962742', '116.388431', 'https://m.tuniucdn.com/fb2/t1/G1/M00/4A/21/Cii-U1k1o-uIdcUZAAIbmIKVlKAAALtvQGBb6kAAhuw170_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1725781423, '上海三迪华美达酒店', '广富林路600弄7号', 690, 43, '华美达', '上海', '四钻', '佘山/松江大学城', '31.058023', '121.246536', 'https://m.tuniucdn.com/fb3/s1/2n9c/NoHym6tuKwVazxy33wRNTNuQWd2_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1734220581, '汉庭酒店(深圳大鹏佳兆业店)', '大鹏街道新园街12号', 378, 43, '汉庭', '深圳', '二钻', '较场尾/大鹏所城', '22.592661', '114.475167', 'https://m.tuniucdn.com/fb3/s1/2n9c/3nWzyWt63gtwPzRf5xbHvwKM27vU_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1754929048, '上海环球港凯悦酒店', '宁夏路718号', 1336, 45, '凯悦', '上海', '五钻', '中山公园商业区', '31.232041', '121.412492', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/B6/Cii-U13ZY-CIF-8MAAXkwQoY7FIAAFpQgEE1bgABeTZ750_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1762661667, '深圳佳兆业万豪酒店', '棕榈大道33号', 223, 46, '万豪', '深圳', '五钻', '较场尾/大鹏所城', '22.569193', '114.459325', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EC/Cii-TF3ZqE-IYM0NAAY6GIHLZNsAAFr2QDhR8EABjow444_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1765008760, '如家酒店(北京西直门北京北站店)', '西直门北大街49号', 356, 44, '如家', '北京', '二钻', '西直门/北京展览馆地区', '39.945106', '116.353827', 'https://m.tuniucdn.com/fb3/s1/2n9c/4CLwbCE9346jYn7nFsJTQXuBExTJ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1880614409, '上海崇明由由喜来登酒店', '揽海路2888号', 2198, 45, '喜来登', '上海', '五钻', '崇明岛/长兴岛/横沙岛', '31.462167', '121.823103', 'https://m.tuniucdn.com/fb3/s1/2n9c/21gDCGgRT3xFqCd3FxBh633j6Qsu_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1889333146, '如家酒店(北京西客站丽泽桥店)', '西三环南路44号-218', 459, 47, '如家', '北京', '二钻', '北京西站/丽泽商务区', '39.869638', '116.313075', 'https://m.tuniucdn.com/fb3/s1/2n9c/kG5corYUDC7U1qE8RAY6xCVnGxq_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1908594080, '上海建工浦江皇冠假日酒店', '陈行公路3701号', 843, 46, '皇冠假日', '上海', '五钻', '浦江镇地区', '31.090063', '121.489728', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/B7/Cii-U13ZZDWIePrGAAPyImW93N0AAFpRgMmj4MAA_I6005_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1913922369, '上海中建万怡酒店', '蟠文路333号', 889, 47, '万怡', '上海', '四钻', '虹桥机场/国家会展中心', '31.185504', '121.287709', 'https://m.tuniucdn.com/fb3/s1/2n9c/39Afm5Bxgd784eMeFB5DrcsPnhT_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1916002015, '上海苏宁环球万怡酒店', '丹巴路99号', 689, 45, '万怡', '上海', '四钻', '长风公园地区', '31.22292', '121.379912', 'https://m.tuniucdn.com/fb3/s1/2n9c/svpYHdmVDck91NqAhjtngcXth2G_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1928731731, '上海康桥万豪酒店', '康新公路4499号', 811, 46, '万豪', '上海', '五钻', '迪士尼度假区', '31.119187', '121.618966', 'https://m.tuniucdn.com/fb3/s1/2n9c/3inpPxTnvRjMCEB39K9FuHaXohYw_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1931442052, '深圳机场凯悦酒店', '宝安国际机场地面交通中心(GTC)18号出口', 291, 47, '凯悦', '深圳', '五钻', '宝安机场商圈', '22.622498', '113.812341', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EC/Cii-TF3ZqVeIJcTPAAUq_Ou_CrcAAFr4gKufPUABSsU446_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1931602865, '深圳联投东方万怡酒店', '松岗东方大道46号', 688, 45, '万怡', '深圳', '五钻', '松岗商业中心区', '22.760746', '113.856961', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/EC/Cii-U13ZqVyIOjdpAARI9aeBh-IAAFr4gOQh7oABEkN297_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1937347815, '北京望京凯悦酒店', '广顺南大街8号院2号楼', 617, 46, '凯悦', '北京', '五钻', '望京/酒仙桥/798地区', '39.991546', '116.476288', 'https://m.tuniucdn.com/fb3/s1/2n9c/2gLT4ZgJ8ZuS7sSmXzYoCXnV248p_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1942938880, '北京乐多港万豪酒店', '城南街道南口路29号', 227, 45, '万豪', '北京', '五钻', '昌平城区/十三陵度假区', '40.23264', '116.188888', 'https://m.tuniucdn.com/fb3/s1/2n9c/3mBWaZeaqq54E7kX2n7g9b2CZX6q_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1942992995, '上海嘉定凯悦酒店', '裕民南路1366号', 758, 46, '凯悦', '上海', '五钻', '嘉定新城', '31.352298', '121.263314', 'https://m.tuniucdn.com/fb2/t1/G6/M00/53/2D/Cii-U13edkqIfZhLAAJEW25WIF4AAGVxQIg38sAAkRz517_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1951709780, '深圳同泰万怡酒店', '福海街道宝安大道 6259号', 617, 48, '万怡', '深圳', '五钻', '深圳国际会展中心商圈', '22.678611', '113.805695', 'https://m.tuniucdn.com/fb3/s1/2n9c/3oUfktphxMAWq9hUxD9uqdjRdZGB_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1973839294, '深圳湾万怡酒店', '科技南路16号', 508, 47, '万怡', '深圳', '五钻', '科技园', '22.531101', '113.950615', 'https://m.tuniucdn.com/fb3/s1/2n9c/8C9QscRsvTWCx92wt17GAegEMFn_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1975922994, '如家酒店·neo(深圳南山海岸城南油地铁站店)', '南商路84-6号', 238, 44, '如家', '深圳', '二钻', '海岸城/后海', '22.513566', '113.9291', 'https://m.tuniucdn.com/fb2/t1/G6/M00/25/5E/Cii-TF3PGD-IQ0FcAAFIZC82AnkAAEVvAKdj4YAAUh8638_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1989806195, '深圳博林天瑞喜来登酒店', '留仙大道4088号', 1369, 48, '喜来登', '深圳', '五钻', '大学城/西丽动物园', '22.582918', '113.97219', 'https://m.tuniucdn.com/fb3/s1/2n9c/4Rx55fZoneUeKbE3TCRSPB6WQ6bw_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1996823660, '上海紫竹万怡酒店', '紫星路588号3幢', 642, 46, '万怡', '上海', '四钻', '交大/闵行经济开发区', '31.02118', '121.465186', 'https://m.tuniucdn.com/fb2/t1/G6/M00/53/2F/Cii-TF3edraIPzK9AAH_p8vdHKoAAGV3AJgSVEAAf-_019_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (1997830708, '和颐至尚酒店(北京上地软件园店)', '清河小营西路48号汇苑仁和大厦一层', 753, 47, '和颐', '北京', '四钻', '上地产业园/西三旗', '40.034623', '116.323925', 'https://m.tuniucdn.com/fb3/s1/2n9c/2sKjxS1hFYyBFVKVBqo2x2hSFvGj_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2003479905, '上海榕港万怡酒店', '新松江路1277号', 798, 46, '万怡', '上海', '四钻', '佘山/松江大学城', '31.038198', '121.210178', 'https://m.tuniucdn.com/fb3/s1/2n9c/2GM761BYH8k15qkNrJrja3cwfr2D_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2009548883, '和颐至尚酒店(北京首都机场新国展店)', '府前二街6号', 611, 46, '和颐', '北京', '三钻', '首都机场/新国展地区', '40.063953', '116.576829', 'https://m.tuniucdn.com/fb3/s1/2n9c/43zCTomkMSkUfZByZxn77YH2XidJ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2011785622, '北京世园凯悦酒店', '阜康南路1号院1号楼A', 558, 47, '凯悦', '北京', '五星级', '延庆休闲度假区', '40.440732', '115.963259', 'https://m.tuniucdn.com/fb3/s1/2n9c/uhGcQze3zZQxe4avSU8BysgYVvx_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2022598930, '上海宝华喜来登酒店', '南奉公路3111弄228号', 2899, 46, '喜来登', '上海', '五钻', '奉贤开发区', '30.921659', '121.575572', 'https://m.tuniucdn.com/fb2/t1/G6/M00/45/BD/Cii-TF3ZaBmIStrbAASnoOyg7FoAAFpYwEoz9oABKe4992_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2022881967, '深圳盐田凯悦酒店', '海景二路1025号1-6层、30-50层', 650, 47, '凯悦', '深圳', '五钻', '盐田区政府/沙头角', '22.551323', '114.23781', 'https://m.tuniucdn.com/fb3/s1/2n9c/2RFMLSujkczEn1HoybD6dUpN9pzr_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2031683181, '和颐至尚酒店(北京雍和宫和平里店)', '小黄庄1区15号', 299, 47, '和颐', '北京', '四钻', '马甸/安贞地区', '39.962361', '116.412931', 'https://m.tuniucdn.com/fb3/s1/2n9c/4Xqm5BN9pZTamwmYS3eLxL417YYt_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2045052822, '深圳国际会展中心皇冠假日酒店', '展云路6号', 675, 47, '皇冠假日', '深圳', '五钻', '深圳国际会展中心商圈', '22.686581', '113.777655', 'https://m.tuniucdn.com/fb3/s1/2n9c/4DGZygQpE4iSpcBDCoXJvjNr4oiR_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2048042240, '北京大兴希尔顿酒店', '高米店南里18号楼', 1283, 48, '希尔顿', '北京', '五钻', '大兴北京新机场地区', '39.76875', '116.339199', 'https://m.tuniucdn.com/fb3/s1/2n9c/3B32F8zSU2CJCWzs1hoH2o4WcquR_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2048047291, '北京新青海喜来登酒店', '丽泽金融商务区凤凰嘴北路与金中都西路交叉口西营街8号院1号楼', 723, 47, '喜来登', '北京', '五钻', '北京西站/丽泽商务区', '39.864026', '116.322505', 'https://m.tuniucdn.com/fb3/s1/2n9c/4DPQMu5sMM7XR1mvcjoqtWngc7TF_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2048050570, '汉庭酒店(深圳坪山火车站店)', '新和路127-2号', 436, 47, '汉庭', '深圳', '二钻', '坪山高铁站商圈', '22.700753', '114.339089', 'https://m.tuniucdn.com/fb3/s1/2n9c/2nXN2bWjfoqoTkPwHvLJQPYz17qD_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2048671293, '汉庭酒店(深圳观澜五和大道店)', '观湖街道五和大道327号', 234, 43, '汉庭', '深圳', '二钻', '观澜', '22.684459', '114.07708', 'https://m.tuniucdn.com/fb3/s1/2n9c/2JrQi83S9qgDEkXqWpe5iyi44Uh2_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2051661320, '汉庭酒店(深圳罗湖口岸万象城二店)', '桂园街道宝安南路1050号嘉宾花园C栋', 667, 47, '汉庭', '深圳', '三钻', '万象城/京基100', '22.540352', '114.112668', 'https://m.tuniucdn.com/fb3/s1/2n9c/34FRP7HLPhvKZP1a6tXu4XrJeiaw_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2056105938, '北京通州北投希尔顿酒店', '新华东街289号2号楼', 1068, 48, '希尔顿', '北京', '五钻', '果园环岛/通州区', '39.908805', '116.659748', 'https://m.tuniucdn.com/fb3/s1/2n9c/NGKdpec3tZJNUUNWJ5pd67Cp5AY_w200_h200_c1_t0.png'); INSERT INTO `hotel` VALUES (2056126831, '上海虹桥金臣皇冠假日酒店', '申长路630弄1-3 号', 2488, 48, '皇冠假日', '上海', '五钻', '虹桥机场/国家会展中心', '31.19036', '121.31535', 'https://m.tuniucdn.com/fb3/s1/2n9c/PvFh4Vzc84xXhm5N41F6AqdAqyJ_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2056132395, '深圳深铁皇冠假日酒店', '深南大道9819号', 340, 47, '皇冠假日', '深圳', '五钻', '科技园', '22.538923', '113.944794', 'https://m.tuniucdn.com/fb3/s1/2n9c/eBLtrED2uJs7yURWfjnWge9dT1P_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2056298828, '上海中优城市万豪酒店', '沪南公路7688弄1号', 1200, 45, '万豪', '上海', '五钻', '南汇/野生动物园', '31.030053', '121.662943', 'https://m.tuniucdn.com/fb3/s1/2n9c/2gBATEyysyQWmw3wZL863HGdqjaq_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2058250574, '深圳湾万丽酒店', '粤海街道高新区社区科技南路18号', 351, 47, '万丽', '深圳', '五钻', '科技园', '22.531674', '113.951882', 'https://m.tuniucdn.com/fb3/s1/2n9c/2YWUpZsvPVkRiKgdPg95LJxaFmB6_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2060510277, '北京金隅八达岭皇冠假日酒店', '妫水北街1号1-14幢', 1026, 44, '皇冠假日', '北京', '五钻', '延庆休闲度假区', '40.476483', '115.97481', 'https://m.tuniucdn.com/fb3/s1/2n9c/3Dzq2KxgiQbmb1sbc5iK6xqpVuFr_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2060618247, '汉庭酒店(深圳海岸城店)', '粤海街道后海社区后海第二统建楼商业裙楼第二层B', 562, 49, '汉庭', '深圳', '二钻', '海岸城/后海', '22.507276', '113.931251', 'https://m.tuniucdn.com/fb3/s1/2n9c/TBoXdgEx5Yjc2HobeC3fPWWnSJi_w200_h200_c1_t0.jpg'); INSERT INTO `hotel` VALUES (2062643512, '深圳国际会展中心希尔顿酒店', '展丰路80号', 285, 46, '希尔顿', '深圳', '五钻', '深圳国际会展中心商圈', '22.705335', '113.77794', 'https://m.tuniucdn.com/fb3/s1/2n9c/2SHUVXNrN5NsXsTUwcd1yaHKbrGq_w200_h200_c1_t0.jpg'); SET FOREIGN_KEY_CHECKS = 1;
如mapper类,service类就自己去创建。
mapping是对索引库中文档的约束,常见的mapping属性包括:
请求方式:PUT
请求路径:/索引库名,可以自定义
请求参数:mapping映射
// PUT/索引库名称 { "mappings": { "properties": { "id": { "type": "keyword" }, "name":{ "type": "text", "analyzer": "ik_max_word", "copy_to": "all" }, "address":{ "type": "keyword", "index": false }, "price":{ "type": "integer" }, "score":{ "type": "integer" }, "brand":{ "type": "keyword", "copy_to": "all" }, "city":{ "type": "keyword", "copy_to": "all" }, "starName":{ "type": "keyword" }, "business":{ "type": "keyword" }, "location":{ "type": "geo_point" }, "pic":{ "type": "keyword", "index": false }, "all":{ "type": "text", "analyzer": "ik_max_word" } } } }
测试结果
/** * @return void * @description 创建索引和映射 * @author King * @date 2023/8/25 17:24 */ @Test void test() { //创建索引 CreateIndexRequest createIndexRequest = new CreateIndexRequest("test"); //创建映射,一般在kibana中写好后再复制过来 createIndexRequest.mapping("{\n" + " \"properties\": {\n" + " \"id\": {\n" + " \"type\": \"keyword\"\n" + " },\n" + " \"name\":{\n" + " \"type\": \"text\",\n" + " \"analyzer\": \"ik_max_word\",\n" + " \"copy_to\": \"all\"\n" + " },\n" + " \"address\":{\n" + " \"type\": \"keyword\",\n" + " \"index\": false\n" + " },\n" + " \"price\":{\n" + " \"type\": \"integer\"\n" + " },\n" + " \"score\":{\n" + " \"type\": \"integer\"\n" + " },\n" + " \"brand\":{\n" + " \"type\": \"keyword\",\n" + " \"copy_to\": \"all\"\n" + " },\n" + " \"city\":{\n" + " \"type\": \"keyword\",\n" + " \"copy_to\": \"all\"\n" + " },\n" + " \"starName\":{\n" + " \"type\": \"keyword\"\n" + " },\n" + " \"business\":{\n" + " \"type\": \"keyword\"\n" + " },\n" + " \"location\":{\n" + " \"type\": \"geo_point\"\n" + " },\n" + " \"pic\":{\n" + " \"type\": \"keyword\",\n" + " \"index\": false\n" + " },\n" + " \"all\":{\n" + " \"type\": \"text\",\n" + " \"analyzer\": \"ik_max_word\"\n" + " }\n" + " }\n" + " }", XContentType.JSON); try { restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new RuntimeException(e); } finally { try { //关闭资源 restHighLevelClient.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
请求方式:GET
请求路径:/索引库名
请求参数:无
GET /索引库名
测试结果
/** * @description 判断索引库是否存在 * * @return void * @author King * @date 2023/8/26 13:38 */ @Test void text4() { GetIndexRequest req = new GetIndexRequest("test"); //如果为 true,则请求仅从本地节点检索信息。 req.local(false); req.humanReadable(true); //如果为 true,则返回响应中的所有默认设置。 req.includeDefaults(false); try { boolean exists = restHighLevelClient.indices().exists(req, RequestOptions.DEFAULT); System.out.println(exists); } catch (IOException e) { throw new RuntimeException(e); }finally { try { restHighLevelClient.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
测试结果
索引库一旦创建,无法修改mapping。
虽然无法修改mapping中已有的字段,但是却允许添加新的字段到mapping中,因为不会对倒排索引产生影响。
请求方式:PUT
请求路径:/索引库名/_mapping
请求参数:mapping映射
PUT /索引库名/_mapping
{
"properties": {
"新字段名":{
"type": "integer"
}
}
}
测试结果
请求方式:DELETE
请求路径:/索引库名
请求参数:无
DELETE /索引库名
/** * @return void * @description 删除索引库 * @author King * @date 2023/8/25 17:26 */ @Test void test2() { //删除索引 DeleteIndexRequest delete = new DeleteIndexRequest("test"); delete.timeout(TimeValue.timeValueMillis(2)); try { restHighLevelClient.indices().delete(delete, RequestOptions.DEFAULT); } catch (IOException e) { throw new RuntimeException(e); } }
请求方式:POST
请求路径:/索引库名/_doc/文档id
请求参数:Json
POST /索引库名/_doc/文档id { { "address": "静安交通路40号", "brand": "7天酒店", "business": "四川北路商业区", "city": "上海", "id": 36934, "latitude": "31.251433", "longitude": "121.47522", "name": "7天连锁酒店(上海宝山路地铁站店)", "pic": "https://m.tuniucdn.com/fb2/t1/G1/M00/3E/40/Cii9EVkyLrKIXo1vAAHgrxo_pUcAALcKQLD688AAeDH564_w200_h200_c1_t0.jpg", "price": 336, "score": 37, "starName": "二钻" } }
测试结果
/** * @description 新增文档 * * @return void * @author King * @date 2023/8/26 15:09 */ @Test void t1() { //查询数据库获取数据 Hotel hotel = hotelMapper.selectById(38812); //转为json String toJSONString = JSON.toJSONString(hotel); IndexRequest indexrequest = new IndexRequest("text"); //指定id indexrequest.id(hotel.getId().toString()); //添加数据 indexrequest.source(toJSONString, XContentType.JSON); //设置Elasticsearch数据刷新策略 indexrequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); try { IndexResponse index = restHighLevelClient.index(indexrequest, RequestOptions.DEFAULT); int status = index.status().getStatus(); System.out.println(status); } catch (IOException e) { throw new RuntimeException(e); } }
测试结果
RefreshPolicy 是WriteRequest接口中的一个内部枚举
IMMEDIATE:
请求向ElasticSearch提交了数据,立即进行数据刷新,然后再结束请求。
优点:实时性高、操作延时短。
缺点:资源消耗高。
WAIT_UNTIL:
请求向ElasticSearch提交了数据,等待数据完成刷新,然后再结束请求。
优点:实时性高、操作延时长。
缺点:资源消耗低。
NONE:
默认策略。
请求向ElasticSearch提交了数据,不关系数据是否已经完成刷新,直接结束请求。
优点:操作延时短、资源消耗低。
缺点:实时性低。
请求方式:GET
请求路径:/索引库名/_doc/文档id
请求参数:无
GET /{索引库名称}/_doc/{id}
测试结果
/** * @description 根据id查询数据 * * @return void * @author King * @date 2023/8/26 16:17 */ @Test void t4() throws IOException { GetRequest getRequest = new GetRequest("test","38812"); GetResponse documentFields = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT); String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } //推荐 @Test void t0() { GetRequest a = new GetRequest("test","36934"); restHighLevelClient.getAsync(a, RequestOptions.DEFAULT, new ActionListener<GetResponse>() { @Override public void onResponse(GetResponse documentFields) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } @Override public void onFailure(Exception e) { e.printStackTrace(); } }); }
测试结果
全量修改是覆盖原来的文档,其本质是:
注意:如果根据id删除时,id不存在,第二步的新增也会执行,也就从修改变成了新增操作了。
请求方式:PUT
请求路径:/{索引库名}/_doc/文档id
请求参数:Json
PUT /{索引库名}/_doc/文档id
{
"address": "徐汇龙华西路315弄58号",
"brand": "7天酒店",
"business": "八万人体育场地区",
"city": "上海",
"id": 38812,
"latitude": "31.174377",
"longitude": "121.442875",
"name": "7天连锁酒店(上海漕溪路地铁站店)",
"pic": "https://m.tuniucdn.com/fb2/t1/G2/M00/E0/0E/Cii-TlkyIr2IEWNoAAHQYv7i5CkAALD-QP2iJwAAdB6245_w200_h200_c1_t0.jpg",
"price": 298,
"score": 37,
"starName": "二钻"
}
测试结果
查询文档,结果已经覆盖
/** * @description 全量修改,id存在修改,不存在新增 * * @return void * @author King * @date 2023/8/26 15:22 */ @Test void t2() { //查询数据库获取数据 Hotel hotel = hotelMapper.selectById(38812); hotel.setAddress("6666"); //转为json String toJSONString = JSON.toJSONString(hotel); IndexRequest indexrequest = new IndexRequest("test"); //指定id indexrequest.id(hotel.getId().toString()); //添加数据 indexrequest.source(toJSONString, XContentType.JSON); //设置Elasticsearch数据刷新策略 indexrequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexrequest.timeout(TimeValue.timeValueSeconds(2)); restHighLevelClient.indexAsync(indexrequest, RequestOptions.DEFAULT, new ActionListener<IndexResponse>() { @Override public void onResponse(IndexResponse indexResponse) { RestStatus status = indexResponse.status(); System.out.println(status.name()); if (indexResponse.getResult() == DocWriteResponse.Result.CREATED) { //id未重复 System.out.println("创建成功"); } else if (indexResponse.getResult() == DocWriteResponse.Result.UPDATED) { //id重复 System.out.println("更新成功"); } } @Override public void onFailure(Exception e) { //出异常了 System.out.println(e.getMessage()); } }); }
测试结果
增量修改是只修改指定id匹配的文档中的部分字段。
请求方式:POST
请求路径:/{索引库名}/_update/文档id
请求参数:json
POST /heima/_update/1
{
"doc": {
"address": "测试地址6",
"brand": "七天酒店6"
}
}
测试结果
查询文档
/** * @description 增量修改,三种常用方式 * * @return void * @author King * @date 2023/8/26 16:07 */ @Test void t3() throws IOException { UpdateRequest update = new UpdateRequest("test","38812"); //1.多个参数拼接 // update.doc("address","测试test", // "brand","测试test"); //2.json // update.doc("{\n" + // " \"address\": \"测试地址test1\",\n" + // " \"brand\": \"七天酒店test1\"\n" + // " }",XContentType.JSON); //3. map Map<String,Object> map = new HashMap<String,Object>(); map.put("address","测试333"); map.put("brand","测试333"); update.doc(map); restHighLevelClient.update(update,RequestOptions.DEFAULT); }
请求方式:DELETE
请求路径:/{索引库名}/_doc/id值
请求参数:无
DELETE /hotel/_doc/1
测试结果
/**
* @description 根据id删除文档
*
* @return void
* @author King
* @date 2023/8/26 16:18
*/
@Test
void t5() throws IOException {
DeleteRequest delete = new DeleteRequest("test","38812");
DeleteResponse response = restHighLevelClient.delete(delete, RequestOptions.DEFAULT);
System.out.println(response.status().name());
}
测试结果
/** * @return void * @description 批量导入 * @author King * @date 2023/8/25 14:56 */ @Test void test1() throws IOException { //查询数据库所有 List<Hotel> hotels = hotelMapper.selectList(null); //批量导入 BulkRequest bulk = new BulkRequest("test"); for (Hotel hotel : hotels) { //数据库中没有location字段,后续经纬度查询需要 Map<String,String> HashMap =new HashMap<>(); HashMap.put("lon",hotel.getLongitude()); HashMap.put("lat",hotel.getLatitude()); hotel.setLocation(HashMap); IndexRequest indexRequest = new IndexRequest().id(hotel.getId().toString()).source(JSON.toJSONString(hotel), XContentType.JSON); //批量添加数据 bulk.add(indexRequest); } restHighLevelClient.bulk(bulk, RequestOptions.DEFAULT); }
Elasticsearch提供了基于JSON的DSL(Domain Specific Language)来定义查询。常见的查询类型包括:
查询所有:查询出所有数据
全文检索(full text)查询:利用分词器对用户输入内容分词,然后去倒排索引库中匹配
精确查询:根据精确词条值查找数据,一般是查找keyword、数值、日期、boolean等类型字段
地理(geo)查询:根据经纬度查询
复合(compound)查询:复合查询可以将上述各种查询条件组合起来,合并查询条件
查询的语法基本一致:
请求方式:GET
请求路径:/{索引库名}/_search
请求参数:json
GET /索引库名/_search
{
"query": {
"查询类型": {
"查询条件": "条件值"
}
}
}
// 查询所有
GET /hotel/_search //不要下面的参数也一样可以
{
"query": {
"match_all": {
}
}
}
测试结果
/** * @description 查询所有 * * @return void * @author King * @date 2023/8/27 10:27 */ @Test void t7() throws IOException { //指定查询的索引名 SearchRequest searchRequest = new SearchRequest("test"); searchRequest.source().query(QueryBuilders.matchAllQuery()); SearchResponse search = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数"+value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } }
测试结果
全文检索查询的基本流程如下:
比较常用的场景包括:
商城的输入框搜索
百度输入框搜索
match查询:单字段查询
multi_match查询:多字段查询,任意一个字段符合条件就算符合查询条件,参与查询字段越多,查询性能越差
GET /test/_search
GET /indexName/_search
{
"query": {
"match": {
"FIELD": "TEXT"
}
}
}
测试结果
{
"query": {
"multi_match": {
"query": "TEXT",
"fields": ["FIELD1", " FIELD12","...", ...]
}
}
}
测试结果
/** * @description 全文检索查询--match--单字段查询 * * @return void * @author King * @date 2023/8/27 11:12 */ @Test void t8() throws IOException { SearchRequest request = new SearchRequest("test"); request.source().query(QueryBuilders.matchQuery("all","酒店")); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } }
测试结果
/** * @description 全文检索查询--multi_match--多字段查询 * * @return void * @author King * @date 2023/8/27 11:13 */ @Test void t9() throws IOException { SearchRequest request = new SearchRequest("test"); request.source().query(QueryBuilders.multiMatchQuery("酒店","brand","name","business")); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } }
测试结果
可以看到,两种查询结果是一样的,是因为mapping映射中我们将brand、name、business值都利用copy_to复制到了all字段中。因此你根据三个字段搜索,和根据all字段搜索效果当然一样了。
但是,搜索字段越多,对查询性能影响越大,因此建议采用copy_to,然后单字段查询的方式。
精确查询一般是查找keyword、数值、日期、boolean等类型字段。所以不会对搜索条件分词
term单值
GET /{索引名}/_search
{
"query": {
"term": {
"FIELD": {
"value": "VALUE"
}
}
}
}
测试结果
terms
GET /indexName/_search
{
"query": {
"terms": {
"FIELD": [
"VALUE1",
"VALUE2"
]
}
}
}
测试结果
term多字段
{
"query": {
"range": {
"FIELD": {
"gte": 10, // 这里的gte代表大于等于,gt则代表大于
"lte": 20 // lte代表小于等于,lt则代表小于
}
}
}
}
测试结果
term单值
/** * @description 精准查询 term查询 * * @return void * @author King * @date 2023/8/27 12:02 */ @Test void t11() throws IOException { SearchRequest request = new SearchRequest("test"); request.source().query(QueryBuilders.termQuery("city","上海"));//替换 SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } }
terms多值
request.source().query(QueryBuilders.termsQuery("city","上海","杭州"));
term多字段
request.source().query(QueryBuilders.termQuery("city","上海"));
request.source().query(QueryBuilders.termQuery("brand","速8"));
/** * @description 精准查询 range查询 * * @return void * @author King * @date 2023/8/27 12:02 */ @Test void t12() throws IOException { SearchRequest request = new SearchRequest("test"); request.source().query(QueryBuilders.rangeQuery("price").gte(100).lte(150)); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } }
矩形范围查询,也就是geo_bounding_box查询,查询坐标落在某个矩形范围的所有文档:
查询时,需要指定矩形的左上、右下两个点的坐标,然后画出一个矩形,落在该矩形内的都是符合条件的点。
附近查询,也叫做距离查询(geo_distance):查询到指定中心点小于某个距离值的所有文档
换句话来说,在地图上找一个点作为圆心,以指定距离为半径,画一个圆,落在圆内的坐标都算符合条件:
多边形查询(geo_polygon),以多个点,确定多边形,获取多边形内的全部数据,与矩形相似,只不过是多个点
// geo_bounding_box查询 GET /indexName/_search { "query": { "geo_bounding_box": { "FIELD": { "top_left": { // 左上点 "lat": 31.1, "lon": 121.5 }, "bottom_right": { // 右下点 "lat": 30.9, "lon": 121.7 } } } } }
测试结果
GET /indexName/_search
{
"query": {
"geo_distance": {
"distance": "15km", // 半径
"FIELD": "31.21,121.5" // 圆心
}
}
}
测试结果
{ "query": { "geo_polygon": { "FIELD": { "points": [ { "lat": 60.9, "lon": 121.7 }, { "lat": 30.9, "lon": 81.7 }, { "lat": 30.9, "lon": 161.7 }, { ... } ] } } } }
测试结果
SearchRequest request = new SearchRequest("test");
request.source().query(QueryBuilders
.geoBoundingBoxQuery("location")
.setCorners(31.1,121.5,30.9,121.7));//纬度,经度,纬度,经度,
SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT);
//结果解析。。。
SearchRequest request = new SearchRequest("test");
request.source().query(QueryBuilders
.geoDistanceQuery("location")
.distance("15", DistanceUnit.KILOMETERS)//半径
.point(31.21,121.5));//圆心
SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT);
//解析响应...
SearchRequest request = new SearchRequest("test");
//import org.elasticsearch.common.geo.GeoPoint;
List<GeoPoint> points=new ArrayList<GeoPoint>();
points.add(new GeoPoint(60.9,121.7));
points.add(new GeoPoint(30.9,81.7));
points.add(new GeoPoint(30.9,161.7));
request.source().query(QueryBuilders.geoPolygonQuery("location",points));
SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT);
//解析响应...
复合(compound)查询:复合查询可以将其它简单查询组合起来,实现更复杂的搜索逻辑。常见的有两种:
当我们利用match查询时,文档结果会根据与搜索词条的关联度打分(_score),返回结果时按照分值降序排列。
TF-IDF算法
TF-IDF算法有一各缺陷,就是词条频率越高,文档得分也会越高,单个词条对文档影响较大
BM25算法,elasticsearch5.1版本后采用的算法
BM25则会让单个词条的算分有一个上限,曲线更加平滑
根据相关度打分是比较合理的需求,但合理的不一定是产品经理需要的。
以百度为例,你搜索的结果中,并不是相关度越高排名越靠前,而是谁掏的钱多排名就越靠前.
要想认为控制相关性算分,就需要利用elasticsearch中的function score 查询了。
{ "query": { "function_score": { "query": { .... }, // 原始查询,可以是任意条件 "functions": [ // 算分函数 { "filter": { // 满足的条件,品牌必须是如家 "term": { "brand": "如家" } }, "weight": 2 // 算分权重为2 } ], "boost_mode": "sum" // 加权模式,求和 } } }
function score 查询中包含四部分内容:
function score的运行流程如下:
因此,其中的关键点是:
过滤条件:决定哪些文档的算分被修改
算分函数:决定函数算分的算法
运算模式:决定最终算分结果
测试结果
/** * @description 算分函数查询 * * @return void * @author King * @date 2023/8/27 16:02 */ @Test void tq() throws IOException { SearchRequest request = new SearchRequest("test"); //原始查询 RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("price").gte(300); FunctionScoreQueryBuilder functionScoreQueryBuilder =QueryBuilders.functionScoreQuery(rangeQueryBuilder, //function score的数组 new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{ //其中的一个function score 元素 new FunctionScoreQueryBuilder.FilterFunctionBuilder( //过滤条件 QueryBuilders.termQuery("brand","如家") //算分函数 /* weightFactorFunction:权重,weight可以让文档在计算分数时乘就weight所指定的数值 scriptFunction:自定义脚本打分,通过写脚本的方法自定义打分,对于某些weight处理不了或不好处理的自定义打分情况可用它来实现 randomFunction:可以生成0到1之间的随机数来给文档打分 fieldValueFactorFunction:field_value_factor函数可以让我们决定由一个field的值来给文档打分,和script_score有相似之处,但是比script_score简单。field _value_factor能完成的功能script_score都能完成。 DecayFunction:衰减函数。类似于通过给定的值来计算出一个圈,然后再给定一个点,求出这个圈子内的数据,距离给定的点越远则打分越低,越近则越高。 gauss(高斯函数) lin(线性函数) exp(指数函数) */ , ScoreFunctionBuilders.weightFactorFunction(10)), // new FunctionScoreQueryBuilder.FilterFunctionBuilder(null,null) 这之后可以继续写function score }); //指定算分为sum functionScoreQueryBuilder.boostMode(CombineFunction.SUM); request.source().query(functionScoreQueryBuilder); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); //打分 float score = documentFields.getScore(); System.out.println("打分:"+score); System.out.println(hotel); } }
布尔查询是一个或多个查询子句的组合,每一个子句就是一个子查询。子查询的组合方式有:
需要注意的是,搜索时,参与打分的字段越多,查询的性能也越差。因此这种多条件查询时,建议这样做:
{ "query": { "bool": { "must": [ {"term": {"city": "上海" }} ], "should": [ {"term": {"brand": "皇冠假日" }}, {"term": {"brand": "华美达" }} ], "must_not": [ { "range": { "price": { "lte": 500 } }} ], "filter": [ { "range": {"score": { "gte": 45 } }} ] } } }
测试结果
/** * @description 布尔查询 * * @return void * @author King * @date 2023/8/27 16:52 */ @Test void tw() throws IOException { SearchRequest request = new SearchRequest("test"); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); //must boolQueryBuilder.must(QueryBuilders.termQuery("city","上海")); //should boolQueryBuilder.should(QueryBuilders.termQuery("brand", "皇冠假日")); boolQueryBuilder.should(QueryBuilders.termQuery("brand", "华美达")); //mustNot boolQueryBuilder.mustNot(QueryBuilders.rangeQuery("price").lte(500)); //filter boolQueryBuilder.filter(QueryBuilders.rangeQuery("score").gte(45)); request.source().query(boolQueryBuilder); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); //文档数组 SearchHit[] hits1 = hits.getHits(); for (SearchHit documentFields : hits1) { String sourceAsString = documentFields.getSourceAsString(); Hotel hotel = JSON.parseObject(sourceAsString, Hotel.class); System.out.println(hotel); } }
elasticsearch默认是根据相关度算分(_score)来排序,但是也支持自定义方式对搜索结果排序。可以排序字段类型有:keyword类型、数值类型、地理坐标类型、日期类型等。
keyword、数值、日期类型排序的语法基本一致。
GET /索引库名/_search
{
"query": {
"match_all": {}
},
"sort": [
{
"FIELD": "desc" // 排序字段、排序方式ASC(升序)、DESC(降序)
},{
...排序条件是一个数组,也就是可以写多个排序条件。按照声明的顺序,当第一个条件相等时,再按照第二个条件排序,以此类推
}
]
}
测试结果
/** * @description 普通字段排序 * * @return void * @author King * @date 2023/8/28 13:31 */ @Test void te() throws IOException { SearchRequest request = new SearchRequest("test"); request.source() .query(QueryBuilders.matchAllQuery()) .sort("score", SortOrder.DESC) .sort("price",SortOrder.ASC); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应... }
GET /索引库名/_search
{
"query": {
"match_all": {}
},
"sort": [
{
"_geo_distance" : {
"FIELD" : "纬度,经度", // 文档中geo_point类型的字段名、目标坐标点
"order" : "asc", // 排序方式
"unit" : "km" // 排序的距离单位
}
}
]
}
测试结果
/** * @description 地理坐标排序 * * @return void * @author King * @date 2023/8/28 13:36 */ @Test void tt() throws IOException { SearchRequest request = new SearchRequest("test"); request.source() .query(QueryBuilders.matchAllQuery()) .sort(SortBuilders .geoDistanceSort("location",31.1,133.4) .order(SortOrder.ASC) .unit(DistanceUnit.KILOMETERS)); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //结果响应。。。 }
elasticsearch 默认情况下只返回top10的数据。而如果要查询更多数据就需要修改分页参数了。elasticsearch中通过修改from、size参数来控制要返回的分页结果:
GET /索引库/_search
{
"query": {
"match_all": {}
},
"from": 0, // 分页开始的位置,默认为0
"size": 10, // 期望获取的文档总数
"sort": [
{"price": "asc"}
]
}
测试结果
/** * @description 分页查询 * * @return void * @author King * @date 2023/8/28 14:05 */ @Test void tr() { SearchRequest request = new SearchRequest("test"); request.source() .query(QueryBuilders.matchAllQuery()) .from(1) .size(10); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); }
高亮显示的实现分为两步:
<em>
标签<em>
标签编写CSS样式{
"query": {
"match": {
"FIELD": "TEXT" // 查询条件,高亮一定要使用全文检索查询
}
},
"highlight": {
"fields": { // 指定要高亮的字段
"FIELD": {
"pre_tags": "<em>", // 用来标记高亮字段的前置标签
"post_tags": "</em>" // 用来标记高亮字段的后置标签
}
}
}
}
注意:
测试结果
/** * @description 高亮 * * @return void * @author King * @date 2023/8/28 14:18 */ @Test void ta() throws IOException { SearchRequest request = new SearchRequest("test"); HighlightBuilder highlightBuilder = new HighlightBuilder(); /* 添加多个高亮字段 List<HighlightBuilder.Field> fields = highlightBuilder.fields(); HighlightBuilder.Field field = new HighlightBuilder.Field("name"); HighlightBuilder.Field field2 = new HighlightBuilder.Field("brand"); field2.requireFieldMatch(false); fields.add(field); fields.add(field2); */ highlightBuilder.field("name"); request.source().query(QueryBuilders.matchQuery("name","如家")).highlighter(highlightBuilder); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); SearchHit[] hits = search.getHits().getHits(); for (SearchHit hit : hits) { // 获取文档source String json = hit.getSourceAsString(); // 反序列化 Hotel hotel = JSON.parseObject(json, Hotel.class); // 获取高亮结果 Map<String, HighlightField> highlightFields = hit.getHighlightFields(); if (!CollectionUtils.isEmpty(highlightFields)) { // 根据字段名获取高亮结果 HighlightField highlightField = highlightFields.get("name"); if (highlightField != null) { // 获取高亮值 String name = highlightField.getFragments()[0].string(); // 覆盖非高亮结果 hotel.setName(name); } } System.out.println(hotel); } }
测试结果
**聚合(aggregations)**可以让我们极其方便的实现对数据的统计、分析、运算。例如:
实现这些统计功能的比数据库的sql要方便的多,而且查询速度非常快,可以实现近实时搜索效果。
聚合常见的有三类:
**桶(Bucket)**聚合:用来对文档做分组
**度量(Metric)**聚合:用以计算一些值,比如:最大值、最小值、平均值等
**管道(pipeline)**聚合:其它聚合的结果为基础做聚合
**注意:**参加聚合的字段必须是keyword、日期、数值、布尔类型
{ "query": { "range": { "price": { "lte": 200 // 只对200元以下的文档聚合 } } }, "size": 0, // 设置size为0,结果中不包含文档,只包含聚合结果 "aggs": { // 定义聚合 "brandAgg": { //给聚合起个名字 "terms": { // 聚合的类型,按照品牌值聚合,所以选择term "field": "brand", // 参与聚合的字段 "order": { "_count": "asc" // 按照_count升序排列 }, "size": 20 // 希望获取的聚合结果数量 } } } }
/** * @return void * @description 桶(Bucket)聚合 - TermAggregation * @author King * @date 2023/8/29 16:54 */ @Test void tz() throws IOException { SearchRequest request = new SearchRequest("test"); request.source() .query(QueryBuilders.rangeQuery("price").lte(200))// 只对200元以下的文档聚合 .aggregation(AggregationBuilders .terms("brandAgg") .field("brand").size(20) .order(BucketOrder.aggregation("_count", true)) .size(20)) .size(0); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); //解析响应 SearchHits hits = search.getHits(); //总条数 long value = hits.getTotalHits().value; System.out.println("总条数" + value); Aggregations aggregations = search.getAggregations(); //Terms继承MultiBucketsAggregation->Aggregation-> Terms brandAgg = aggregations.get("brandAgg"); List<? extends Terms.Bucket> buckets = brandAgg.getBuckets(); for (Terms.Bucket bucket : buckets) { String keyAsString = bucket.getKeyAsString(); System.out.println(keyAsString); } }
继承关系图
参数
{ "size": 0, "aggs": { "brandAgg": { "terms": { "field": "brand", "size": 20 }, "aggs": { // 是brands聚合的子聚合,也就是分组后对每组分别计算 "score_avg": { // 聚合名称 "avg": { // 聚合类型,计算min、max、avg等 "field": "score" // 聚合字段,这里是score } } } } } }
测试结果
{ "size": 0, "aggs": { "brandAgg": { "terms": { "field": "brand", "size": 20 }, "aggs": { // 是brands聚合的子聚合,也就是分组后对每组分别计算 "score_stats": { // 聚合名称 "stats": { // 聚合类型,这里stats可以计算min、max、avg等 "field": "score" // 聚合字段,这里是score } } } } } }
测试结果
/** * @description 度量(Metric)-Avg/Sum/Max/Min * * @return void * @author King * @date 2023/9/4 9:17 */ @Test void tx() throws IOException { SearchRequest request = new SearchRequest("test"); request.source() .size(0) .aggregation(AggregationBuilders .terms("brandAgg") .field("brand") .size(20).subAggregation(AggregationBuilders .avg("score_avg") .field("score"))); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); Aggregations aggregations = search.getAggregations(); //Terms继承MultiBucketsAggregation->Aggregation-> Terms brandAgg = aggregations.get("brandAgg"); List<? extends Terms.Bucket> buckets = brandAgg.getBuckets(); buckets.forEach(i -> { String keyAsString = i.getKeyAsString(); System.out.print(keyAsString + " "); Aggregations aggregations1 = i.getAggregations(); //Aggregation的一个子实现 ParsedAvg score_avg = aggregations1.get("score_avg"); double value = score_avg.getValue(); System.out.println(value); }); }
/** * @description 度量(Metric)-Stats * * @return void * @author King * @date 2023/9/4 9:17 */ @Test void tl() throws IOException { SearchRequest request = new SearchRequest("test"); request.source() .size(0) .aggregation(AggregationBuilders .terms("brandAgg") .field("brand") .size(20).subAggregation(AggregationBuilders .stats("score_stats") .field("score"))); SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT); Aggregations aggregations = search.getAggregations(); //Terms继承MultiBucketsAggregation->Aggregation-> Terms brandAgg = aggregations.get("brandAgg"); List<? extends Terms.Bucket> buckets = brandAgg.getBuckets(); buckets.forEach(i -> { String keyAsString = i.getKeyAsString(); System.out.print(keyAsString + " "); Aggregations aggregations1 = i.getAggregations(); //Aggregation的一个子实现 ParsedStats score_avg = aggregations1.get("score_stats"); double avg = score_avg.getAvg(); double max = score_avg.getMax(); double min = score_avg.getMin(); double sum = score_avg.getSum(); System.out.println("avg:"+avg+"max:"+max+"min"+min+"sum"+sum); }); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。