springboot使用RestHighLevelClient7简单操作ElasticSearch7增删查改/索引创建
本次操作是在 Windows上安装ElasticSearch7 进行操作
导入依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.es.demo</groupId>
<artifactId>elastic-search-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>elastic-search-demo</name>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
<elasticsearch.version>7.3.2</elasticsearch.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Java High Level REST Client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<!-- commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<!-- fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.54</version>
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
application.yml
server:
port: 8833
spring:
application:
name: elastic_search
#es http方式
elasticsearch:
address: localhost:9200
# username: admin
# password: admin
es配置加载
package com.es.demo.config; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import java.util.Arrays;
import java.util.Objects; /**
* es RestHighLevelClient 配置
* es 7.x之后 只支持http
* @author qjc
* @date 2019-07-19 10:33
*/
@Configuration
@Slf4j
public class ESConfig {
private static final int ADDRESS_LENGTH = 2;
private static final String HTTP_SCHEME = "http";
//权限验证
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); /**
* 使用冒号隔开ip和端口
*/
@Value("${elasticsearch.address}")
private String[] address; // @Value("${elasticsearch.username}")
// private String username; // @Value("${elasticsearch.password}")
// private String password; @Bean
public RestClientBuilder restClientBuilder() {
HttpHost[] hosts = Arrays.stream(address)
.map(this::makeHttpHost)
.filter(Objects::nonNull)
.toArray(HttpHost[]::new);
log.debug("hosts:{}", Arrays.toString(hosts));
//配置权限验证
// credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
RestClientBuilder restClientBuilder = RestClient.builder(hosts).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
});
return restClientBuilder;
} @Bean(name = "highLevelClient")
public RestHighLevelClient highLevelClient(@Autowired RestClientBuilder restClientBuilder) {
// restClientBuilder.setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(restClientBuilder);
} /**
* 处理请求地址
* @param s
* @return HttpHost
*/
private HttpHost makeHttpHost(String s) {
assert StringUtils.isNotEmpty(s);
String[] address = s.split(":");
if (address.length == ADDRESS_LENGTH) {
String ip = address[0];
int port = Integer.parseInt(address[1]);
return new HttpHost(ip, port, HTTP_SCHEME);
} else {
return null;
}
}
}
swagger
package com.es.demo.swagger; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration // 启动时就要加载
@EnableSwagger2
public class SwaggerConfig {
private String version; @Bean
public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2)
.genericModelSubstitutes(DeferredResult.class)
.select()
.paths(PathSelectors.any())
.build().apiInfo(apiInfo());//.globalOperationParameters(pars); } private ApiInfo apiInfo() { return new ApiInfoBuilder().title("Earth server")
.description("****")
.termsOfServiceUrl("http://www.baidu.com")
.version("1.0").build();
}
}
插入的实体:
package com.es.demo.vo; import lombok.Data; /**
* @Description:
* @Param:
* @Return:
* @Author: qjc
* @Date: 2019/10/18
*/
@Data //IDEA需要安装lombok:https://www.cnblogs.com/java-spring/p/9797560.html
public class User { private String name; private int age; private Double money; private String address; private String birthday;
}
响应实体
package com.es.demo.vo; import lombok.AllArgsConstructor;
import lombok.Data; @Data
@AllArgsConstructor
public class ResponseBean {
//状态码
private Integer code;
//返回信息
private String message;
//返回的数据
private Object data; }
es操作
创建索引时需要用到IK分词器,请参考: Windows上安装ElasticSearch7的IK分词器
package com.es.demo.controller; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.es.demo.utils.ESUtil;
import com.es.demo.vo.ResponseBean;
import com.es.demo.vo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.replication.ReplicationResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedLongTerms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortMode;
import org.springframework.web.bind.annotation.*; import javax.annotation.Resource;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; /**
* @Author: qjc
* @Date: 2019/09/18
*/
@Api(value = "ES测试接口", tags = {"ES测试接口"})
@RestController
@RequestMapping("/es")
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT})
@Slf4j
public class ESTestController { @Resource
private RestHighLevelClient restHighLevelClient;
@Resource
ESUtil esUtil; @ApiOperation(value = "es测试创建索引接口", notes = "es测试创建索引接口")
@RequestMapping(value = "/create/index", method = RequestMethod.POST)
public ResponseBean createIndex(@RequestParam String indexName) {
try {
XContentBuilder builder = XContentFactory.jsonBuilder()
.startObject()
.field("properties")
.startObject()
.field("name").startObject().field("index", "true").field("type", "keyword").endObject()
.field("age").startObject().field("index", "true").field("type", "integer").endObject()
.field("money").startObject().field("index", "true").field("type", "double").endObject()
.field("address").startObject().field("index", "true").field("type", "text").field("analyzer", "ik_max_word").endObject()
.field("birthday").startObject().field("index", "true").field("type", "date").field("format", "strict_date_optional_time||epoch_millis").endObject()
.endObject()
.endObject();
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
createIndexRequest.mapping(builder);
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);
boolean acknowledged = createIndexResponse.isAcknowledged();
if (acknowledged) {
return new ResponseBean(200, "创建成功", null);
} else {
return new ResponseBean(1002, "创建失败", null);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
} @ApiOperation(value = "es测试是否存在索引接口", notes = "es测试是否存在索引接口")
@RequestMapping(value = "/index/exists", method = RequestMethod.POST)
public ResponseBean indexExists(@RequestParam String indexName) {
boolean isExists = esUtil.isIndexExists(indexName);
return new ResponseBean(200, "查询成功", isExists);
} @ApiOperation(value = "es测试删除索引接口", notes = "es测试删除索引接口")
@RequestMapping(value = "/delete/index", method = RequestMethod.POST)
public ResponseBean deleteIndex(@RequestParam String indexName) {
boolean isDelete = esUtil.deleteIndex(indexName);
if (isDelete) {
return new ResponseBean(200, "删除成功", null);
} else {
return new ResponseBean(10002, "删除失败", null);
}
} @ApiOperation(value = "es测试插入接口", notes = "es测试插入接口")
@RequestMapping(value = "/insert/data", method = RequestMethod.POST)
public ResponseBean findIndustryClassList(@RequestBody User user, @RequestParam String indexName) {
IndexRequest indexRequest = new IndexRequest(indexName);
String userJson = JSONObject.toJSONString(user);
indexRequest.source(userJson, XContentType.JSON);
try {
IndexResponse indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
if (indexResponse != null) {
String id = indexResponse.getId();
String index = indexResponse.getIndex();
long version = indexResponse.getVersion();
log.info("index:{},id:{}", index, id);
if (indexResponse.getResult() == DocWriteResponse.Result.CREATED) {
System.out.println("新增文档成功!" + index + "-" + id + "-" + version);
return new ResponseBean(200, "插入成功", id);
} else if (indexResponse.getResult() == DocWriteResponse.Result.UPDATED) {
System.out.println("修改文档成功!");
return new ResponseBean(10001, "插入失败", null);
}
// 分片处理信息
ReplicationResponse.ShardInfo shardInfo = indexResponse.getShardInfo();
if (shardInfo.getTotal() != shardInfo.getSuccessful()) {
System.out.println("分片处理信息.....");
}
// 如果有分片副本失败,可以获得失败原因信息
if (shardInfo.getFailed() > 0) {
for (ReplicationResponse.ShardInfo.Failure failure : shardInfo.getFailures()) {
String reason = failure.reason();
System.out.println("副本失败原因:" + reason);
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
} @ApiOperation(value = "es测试普通查询接口", notes = "es测试普通查询接口")
@RequestMapping(value = "/query/data", method = RequestMethod.GET)
public ResponseBean testESFind() {
SearchRequest searchRequest = new SearchRequest("test_es");
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
//如果用name直接查询,其实是匹配name分词过后的索引查到的记录(倒排索引);如果用name.keyword查询则是不分词的查询,正常查询到的记录
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("birthday").from("1991-01-01").to("2010-10-10").format("yyyy-MM-dd");//范围查询
// TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("name.keyword", name);//精准查询
PrefixQueryBuilder prefixQueryBuilder = QueryBuilders.prefixQuery("name.keyword", "张");//前缀查询
// WildcardQueryBuilder wildcardQueryBuilder = QueryBuilders.wildcardQuery("name.keyword", "*三");//通配符查询
// FuzzyQueryBuilder fuzzyQueryBuilder = QueryBuilders.fuzzyQuery("name", "三");//模糊查询
FieldSortBuilder fieldSortBuilder = SortBuilders.fieldSort("age");//按照年龄排序
fieldSortBuilder.sortMode(SortMode.MIN);//从小到大排序 BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(rangeQueryBuilder).should(prefixQueryBuilder);//and or 查询 sourceBuilder.query(boolQueryBuilder).sort(fieldSortBuilder);//多条件查询
sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
searchRequest.source(sourceBuilder);
try {
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = response.getHits();
JSONArray jsonArray = new JSONArray();
for (SearchHit hit : hits) {
String sourceAsString = hit.getSourceAsString();
JSONObject jsonObject = JSON.parseObject(sourceAsString);
jsonArray.add(jsonObject);
}
return new ResponseBean(200, "查询成功", jsonArray);
} catch (IOException e) {
e.printStackTrace();
return new ResponseBean(10001, "查询失败", null);
}
} @ApiOperation(value = "es测试聚合查询接口", notes = "es测试聚合查询接口")
@RequestMapping(value = "/query/agg", method = RequestMethod.GET)
public ResponseBean testESFindAgg() {
SearchRequest searchRequest = new SearchRequest("test_es");
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); TermsAggregationBuilder termsAggregationBuilder = AggregationBuilders.terms("by_age").field("age");
sourceBuilder.aggregation(termsAggregationBuilder); sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
searchRequest.source(sourceBuilder); try {
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
Aggregations aggregations = searchResponse.getAggregations();
Map<String, Aggregation> stringAggregationMap = aggregations.asMap();
ParsedLongTerms parsedLongTerms = (ParsedLongTerms) stringAggregationMap.get("by_age");
List<? extends Terms.Bucket> buckets = parsedLongTerms.getBuckets();
Map<Integer, Long> map = new HashMap<>();
for (Terms.Bucket bucket : buckets) {
long docCount = bucket.getDocCount();//个数
Number keyAsNumber = bucket.getKeyAsNumber();//年龄
System.err.println(keyAsNumber + "岁的有" + docCount + "个");
map.put(keyAsNumber.intValue(), docCount);
}
return new ResponseBean(200, "查询成功", map);
} catch (IOException e) {
e.printStackTrace();
}
return null;
} @ApiOperation(value = "es测试更新接口", notes = "es测试更新接口")
@RequestMapping(value = "/update/data", method = RequestMethod.GET)
public ResponseBean testESUpdate(@RequestParam String id, @RequestParam Double money) {
UpdateRequest updateRequest = new UpdateRequest("test_es", id);
Map<String, Object> map = new HashMap<>();
map.put("money", money);
updateRequest.doc(map);
try {
UpdateResponse updateResponse = restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
if (updateResponse.getResult() == DocWriteResponse.Result.UPDATED) {
return new ResponseBean(200, "更新成功", null);
} else {
return new ResponseBean(10002, "删除失败", null);
}
} catch (IOException e) {
e.printStackTrace();
return new ResponseBean(1003, "删除异常", null);
}
} @ApiOperation(value = "es测试删除接口", notes = "es测试删除接口")
@RequestMapping(value = "/delete/data", method = RequestMethod.GET)
public ResponseBean testESDelete(@RequestParam String id, @RequestParam String indexName) {
DeleteRequest deleteRequest = new DeleteRequest(indexName);
deleteRequest.id(id);
try {
DeleteResponse deleteResponse = restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
return new ResponseBean(1001, "删除失败", null);
} else {
return new ResponseBean(200, "删除成功", null);
}
} catch (IOException e) {
e.printStackTrace();
return new ResponseBean(1003, "删除异常", null);
}
}
}
package com.es.demo.utils; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.springframework.stereotype.Component; import javax.annotation.Resource;
import java.io.IOException; /**
* @Description:
* @Author: qjc
* @Date: 2019/10/30
*/
@Component
public class ESUtil { @Resource
RestHighLevelClient restHighLevelClient; /**
* 判断索引是否存在
*
* @param indexName
* @return
*/
public boolean isIndexExists(String indexName) {
boolean exists = false;
try {
GetIndexRequest getIndexRequest = new GetIndexRequest(indexName);
getIndexRequest.humanReadable(true);
exists = restHighLevelClient.indices().exists(getIndexRequest,RequestOptions.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
}
return exists;
} /**
* 删除索引
*
* @param indexName
* @return
*/
public boolean deleteIndex(String indexName) {
boolean acknowledged = false;
try {
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName);
deleteIndexRequest.indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN);
AcknowledgedResponse delete = restHighLevelClient.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
acknowledged = delete.isAcknowledged();
} catch (IOException e) {
e.printStackTrace();
}
return acknowledged;
} }
创建索引成功后,可以用以下方式查看
通过访问swagger http://localhost:8833/swagger-ui.html#/ 可以进行如下操作
源码地址:
https://gitee.com/xiaorenwu_dashije/es_search_demo.git
springboot使用RestHighLevelClient7简单操作ElasticSearch7增删查改/索引创建的更多相关文章
- 在Eclipse上实现简单的JDBC增删查改操作
在Javaweb的学习里,学到了如何完成简单的增删查改操作,在这里撰写一篇文章以便自己整理回忆. 首先要建立一些包和导入一些文件.建一些类.具体框架如图 编写Product类 public clas ...
- python操作mysql增删查改
# coding=utf-8 ''' python操作mysql,需安装MySQLdb驱动 安装MySQLdb,请访问 http://sourceforge.net/projects/mysql-py ...
- Mysql 单表操作、增删查改(基础4)
新建一个表,往里面插入数据. #新建一个表 mysql> create table test( -> id int, -> name varchar(20) -> );Quer ...
- jQuery-DOM增删查改
1.绑定事件 $().事件名(function(){功能}) 事件名:鼠标事件 键盘事件 表单事件 事件委托:$().on('事件名',#####'target',function(){功能}) 额外 ...
- Java连接MySQL数据库及简单的增删查改操作
主要摘自 https://www.cnblogs.com/town123/p/8336244.html https://www.runoob.com/java/java-mysql-connect.h ...
- nodejs连接mysql并进行简单的增删查改
最近在入门nodejs,正好学习到了如何使用nodejs进行数据库的连接,觉得比较重要,便写一下随笔,简单地记录一下 使用在安装好node之后,我们可以使用npm命令,在项目的根目录,安装nodejs ...
- java实现简单的数据库的增删查改,并布局交互界面
一.系统简介 1.1.简介 本系统提供了学生信息管理中常见的基本功能,主要包括管理员.管理员的主要功能有对学生信息进行增加.删除.修改.查找等操作,对信息进行管理,对信息进行修改.查找等操作 ...
- PHP与MYSQL结合操作——文章发布系统小项目(实现基本增删查改操作)
php和mysql在一起几十年了,也是一对老夫老妻了,最近正在对他们的爱情故事进行探讨,并做了一个很简单的小东西——文章发布系统,目的是为了实现mysql对文章的基本增删查改操作 前台展示系统有:文章 ...
- SpringBoot整合Mybatis-plus实现增删查改
今天给大家分享一下SpringBoot整合Mybatis-plus的增删查改案例. pom.xml <?xml version="1.0" encoding="UT ...
随机推荐
- android studio如何连接夜神模拟器
原创 2018-02-05 21:35:03 会飞的鱼儿android 阅读数 16706 文章标签: 夜神模拟器连接夜神模拟器的简单方式 更多 分类专栏: Android 版权声明:本文为博主原 ...
- Zookeeper:Unable to read additional data from client sessionid 0x00, likely client has closed socket
异常信息: 2018-03-20 23:34:01,887 [myid:99] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerC ...
- docker stack删除network失败
现象描述 删除stack的时候没太多提示,但再启动相同的stack会报错,提示网络创建失败:随后使用network ls命令可以看到之前的network还在: 使用docker network rm还 ...
- CentOS6非root用户下安装及配置CDH5.3.0
#install lsb packagesudo yum install -y redhat-lsb #install net-tools package sudo yum install -y ne ...
- 查找算法(6)--Block search--分块查找
1. 分块查找 (1)说明分块查找又称索引顺序查找,它是顺序查找的一种改进方法. (2)算法思想:将n个数据元素"按块有序"划分为m块(m ≤ n).每一块中的结点不必有序,但块与 ...
- elementUI vue this.$confirm 和el-dialog 弹出框 移动
调试了好久, 还能凑合用, 请直接看DOME 示例,复制就能用: <!DOCTYPE html> <html lang="zh"> <head> ...
- Qt编写安防视频监控系统(界面很漂亮)
一.前言 视频监控系统在整个安防领域,已经做到了烂大街的程序,全国起码几百家公司做过类似的系统,当然这一方面的需求量也是非常旺盛的,各种定制化的需求越来越多,尤其是这几年借着人脸识别的东风,发展更加迅 ...
- 为什么重写equals时一定要重写hashcode
我们开发时写一个类,默认继承Object类,Object类的equals方法是比较是否指向同一个对象(地址是否相同), Object类 的hashcode方法返回的对象内存地址的值, 一个类只重写了e ...
- 1-3docker commit定制镜像
以定制⼀个 Web 服务器为例⼦ 1.commit定制镜像 docker pull nginx:1.17 运行容器 --name:容器名字 -d:后台 -p本地端口:容器内端口 docker ru ...
- [教程]Tensorflow + win10 + CPU + Python3.6+ 安装教程
由于各种原因,清华镜像源已经彻底挂掉了,但是目前网上的各种教程基本上都是采取设置清华镜像源来加快下载速度,所以这给小白带来了很大的困扰!这里我将通过合理上网工具来直接下载源镜像. 注意:本次教程适用于 ...