Elsaticsearch java基本操作

索引 基本操作
package com.orchids.elasticsearch.web.controller;import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.orchids.elasticsearch.web.po.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
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.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;/*** @ Author qwh* @ Date 2024/7/12 19:18*/
@Slf4j
@Api(tags = "索引")
@RestController
@RequestMapping("/elastic/index")
@RequiredArgsConstructor
public class ElasticIndexController {private final RestHighLevelClient client;static final String MAPPING_TEMPLATE = "{\n" +"  \"mappings\": {\n" +"    \"properties\": {\n" +"      \"name\":{\n" +"        \"type\": \"text\",\n" +"        \"analyzer\": \"ik_max_word\"\n" +"      },\n" +"      \"age\":{\n" +"        \"type\": \"integer\"\n" +"      },\n" +"      \"sex\":{\n" +"        \"type\": \"text\"\n" +"      }\n" +"    }\n" +"  }\n" +"}";@ApiOperation("添加索引")@PostMapping("/add")public String CreateIndex(@RequestParam("index") String index) throws IOException {CreateIndexRequest request = new CreateIndexRequest(index);request.source(MAPPING_TEMPLATE, XContentType.JSON);CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT);log.error("response{}",response);if (response!=null){return "add index success";}else {return "add index fail";}}@ApiOperation("獲取索引")@GetMapping("/get")public Map<String, Object> GetIndex(@RequestParam("index") String index) throws IOException {//創建請求對象GetIndexRequest request = new GetIndexRequest(index);//發送請求GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);// todo 健壯性if (client.indices().exists(request,RequestOptions.DEFAULT)){MappingMetadata data = response.getMappings().get(index);return data.getSourceAsMap();}else {return null;}}/*** 查看指定索引的映射信息。* <p>* 通過該接口,可以獲取Elasticsearch中指定索引的映射設置。映射(Mapping)定義了字段的類型和分析器等配置,* 對于查詢和分析數據至關重要。此方法接收一個索引名稱作為參數,返回該索引的映射配置。** @param index 指定的索引名稱,用于獲取該索引的映射信息。* @return 包含指定索引映射配置的Map對象。* @throws IOException 如果獲取映射信息時發生I/O錯誤。*/@ApiOperation("查看映射")@GetMapping("/mapper")public Map<String, Object> Index(@RequestParam("index") String index) throws IOException {// todo 健壯性// 創建GetIndexRequest對象,指定要獲取映射信息的索引。GetIndexRequest request = new GetIndexRequest(index);// 執行請求,獲取索引的映射響應。GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);// 從響應中提取映射配置。Map<String, MappingMetadata> mappings = response.getMappings();// 獲取指定索引的映射元數據。MappingMetadata metadata = mappings.get(index);// 從映射元數據中提取源映射配置。Map<String, Object> source = metadata.getSourceAsMap();// 返回源映射配置。return source;}@ApiOperation("刪除索引")@DeleteMapping("/del")public String  DeleteIndex(@RequestParam("index") String index) throws IOException {//創建請求對象DeleteIndexRequest request = new DeleteIndexRequest(index);//發送請求return client.indices().delete(request, RequestOptions.DEFAULT)!=null ? index+"刪除成功" : index+"刪除失敗";}}
文檔
package com.orchids.elasticsearch.web.controller;import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orchids.elasticsearch.web.po.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
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.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.springframework.web.bind.annotation.*;import java.io.IOException;
import java.util.LinkedList;
import java.util.List;/*** @ Author qwh* @ Date 2024/7/12 21:31*/
@Slf4j
@Api(tags = "文檔")
@RestController
@RequestMapping("/elastic/doc")
@RequiredArgsConstructor
public class ElasticDocumentController {private final RestHighLevelClient client;@ApiOperation("添加文檔")@PostMapping("/add")public String addDocument(@RequestParam("index") String index, @RequestBody User user) throws IOException {if (user==null) {throw new RuntimeException("非法參數");}String jsonUser = JSONUtil.toJsonStr(user);System.out.println(jsonUser);//準備請求對象IndexRequest request = new IndexRequest(index).id(user.getName());//準備json文檔request.source(jsonUser, XContentType.JSON);//發送請求 putIndexResponse response = client.index(request, RequestOptions.DEFAULT);if (response!=null){return "success";}else {return "fail";}}@ApiOperation("獲取文檔")@GetMapping("/get")public User getDocument(@RequestParam("id") String id,@RequestParam("index") String index) throws IOException {//準備請求對象 參數:索引庫 文檔idGetRequest request = new GetRequest(index).id(id);//發送請求 得到json格式響應GetResponse response = client.get(request, RequestOptions.DEFAULT);String jsonBean = response.getSourceAsString();log.error("響應response{}",jsonBean);User bean = JSONUtil.toBean(jsonBean, User.class);System.out.println(bean);return bean;}@ApiOperation("所有文檔")@GetMapping("/all")public List<User> allDocument(@RequestParam String index) throws IOException {//準備請求對象 參數索引SearchRequest request = new SearchRequest(index);//請求參數request.source().query(QueryBuilders.matchAllQuery());//發送請求 并返回響應SearchResponse response = client.search(request, RequestOptions.DEFAULT);//解析響應return handleResponse(response);}private List<User> handleResponse(SearchResponse response) {SearchHits searchHits = response.getHits();//獲取總條數long total = searchHits.getTotalHits().value;log.error("一共搜索到{}條數據",total);//遍歷數組SearchHit[] hits = searchHits.getHits();List<User> users = new LinkedList<>();for (SearchHit hit : hits) {//得到每一個數組的_source 原始的json文檔String source = hit.getSourceAsString();log.error("原始的json格式{}",source);//反序列化User user = JSONUtil.toBean(source, User.class);log.error("放序列化后json格式{}",user);users.add(user);}return users;}@ApiOperation("刪除文檔")@DeleteMapping("/del")public String updateDocument(@RequestParam("index") String index,@RequestParam("id")String id) throws IOException {//requestDeleteRequest request = new DeleteRequest(index,id);//修改內容DeleteResponse delete = client.delete(request, RequestOptions.DEFAULT);if (delete!=null){return "success";}else {return "fail";}}@ApiOperation("修改文檔")@PostMapping("/update")public String updateDocument(@RequestParam("index") String index,@RequestBody User user) throws IOException {if (user.getName()==null) {return "id參數非法";}//requestUpdateRequest request = new UpdateRequest(index,user.getName());//修改內容request.doc("name",user.getName(),"age",user.getAge(),"sex",user.getSex());//發送請求//當es中沒有對應的id 添加該idtry {//修改client.update(request, RequestOptions.DEFAULT);} catch (ElasticsearchStatusException e) {//添加String jsonUser = JSONUtil.toJsonStr(user);System.out.println(jsonUser);//準備請求對象IndexRequest req = new IndexRequest(index).id(user.getName());//準備json文檔req.source(jsonUser, XContentType.JSON);//添加client.index(req,RequestOptions.DEFAULT);}return "修改成功";}@ApiOperation("批量添加")@PutMapping("/adds")public String LoadDocument() throws IOException {return "todo";
//        int current = 1;
//        int size = 100;
//        while (true){
//            Page<User> page = new Page<>(current, size);
//            List<User> users = page.getRecords();
//            if (CollUtil.isEmpty(users)) {
//                return null;
//            }
//            log.info("加載第{}頁數據共{}條", current, users.size());
//            //創建request
//            BulkRequest request = new BulkRequest("user");
//            //準備參數
//            for (User user : users) {
//
//    /*            IndexRequest indexRequest = new IndexRequest().id(user.getName());
//                indexRequest.source(JSONUtil.toJsonStr(user),XContentType.JSON);
//                request.add(indexRequest);*/
//
//                request.add(new IndexRequest().id(user.getName()).source(JSONUtil.toJsonStr(user), XContentType.JSON));
//            }
//            client.bulk(request, RequestOptions.DEFAULT);
//            current++;
//        }}
}
Java client
package com.orchids.elasticsearch.web.controller;import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.orchids.elasticsearch.web.po.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.web.bind.annotation.*;import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;/*** @ Author qwh* @ Date 2024/7/12 21:48*/
@Slf4j
@Api(tags = "Restapi")
@RestController
@RequestMapping("/elastic/rest")
@RequiredArgsConstructor
public class ElasticRestController {private final RestHighLevelClient client;
//    @GetMapping()public void testAgg() throws IOException {// 1.創建RequestSearchRequest request = new SearchRequest("items");// 2.準備請求參數BoolQueryBuilder bool = QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("category", "手機")).filter(QueryBuilders.rangeQuery("price").gte(300000));request.source().query(bool).size(0);// 3.聚合參數request.source().aggregation(AggregationBuilders.terms("brand_agg").field("brand").size(5));// 4.發送請求SearchResponse response = client.search(request, RequestOptions.DEFAULT);// 5.解析聚合結果Aggregations aggregations = response.getAggregations();// 5.1.獲取品牌聚合Terms brandTerms = aggregations.get("brand_agg");// 5.2.獲取聚合中的桶List<? extends Terms.Bucket> buckets = brandTerms.getBuckets();// 5.3.遍歷桶內數據for (Terms.Bucket bucket : buckets) {// 5.4.獲取桶內keyString brand = bucket.getKeyAsString();System.out.print("brand = " + brand);long count = bucket.getDocCount();System.out.println("; count = " + count);}}@ApiOperation("高亮查詢")@GetMapping("/high") //high okpublic List<User> HighlightQuery(@ApiParam(name = "index",value = "索引",required = true) @RequestParam("index")String index,@ApiParam(name = "high",value = "高亮條件",required = true)@RequestParam("high") String high ) throws IOException {// 1.創建RequestSearchRequest request = new SearchRequest(index);// 2.組織請求參數// 2.1.query條件request.source().query(QueryBuilders.matchQuery("name", high));// 2.2.高亮條件request.source().highlighter(SearchSourceBuilder.highlight().field("name").preTags("<em>").postTags("</em>"));// 3.發送請求SearchResponse response = client.search(request, RequestOptions.DEFAULT);// 4.解析響應return hand(response);}private List<User> hand(SearchResponse response) {SearchHits searchHits = response.getHits();// 1.獲取總條數long total = searchHits.getTotalHits().value;System.out.println("共搜索到" + total + "條數據");// 2.遍歷結果數組SearchHit[] hits = searchHits.getHits();List<User> result = new LinkedList<>();for (SearchHit hit : hits) {// 3.得到_source,也就是原始json文檔String source = hit.getSourceAsString();// 4.反序列化User user = JSONUtil.toBean(source, User.class);// 5.獲取高亮結果Map<String, HighlightField> hfs = hit.getHighlightFields();if (CollUtil.isNotEmpty(hfs)) {// 5.1.有高亮結果,獲取name的高亮結果HighlightField hf = hfs.get("name");if (hf != null) {// 5.2.獲取第一個高亮結果片段,就是商品名稱的高亮值String hfName = hf.getFragments()[0].string();user.setName(hfName);}}result.add(user);}return result;}@ApiOperation("分頁查詢")@GetMapping("/page")public List <User> pageQuery(@ApiParam(value = "索引",required = true)@RequestParam("index")String index,@ApiParam(value = "字段條件",required = true)@RequestParam("field") String field,@ApiParam(value = "當前頁",required = true)@RequestParam("current")String current,@ApiParam(value = "頁大小",required = true)@RequestParam("size")String size) throws IOException {// 1.創建RequestSearchRequest request = new SearchRequest(index);// 2.組織請求參數// 2.1.搜索條件參數request.source().query(QueryBuilders.matchQuery("name", field));// 2.2.排序參數request.source().sort("age", SortOrder.ASC);// 2.3.分頁參數request.source().from((Integer.valueOf(current) - 1) * Integer.valueOf(size)).size(Integer.valueOf(size));// 3.發送請求SearchResponse response = client.search(request, RequestOptions.DEFAULT);// 4.解析響應return handleResponse(response);}private List <User> handleResponse(SearchResponse response) {SearchHits searchHits = response.getHits();// 1.獲取總條數long total = searchHits.getTotalHits().value;System.out.println("共搜索到" + total + "條數據");// 2.遍歷結果數組SearchHit[] hits = searchHits.getHits();List<User> result = new LinkedList<>();for (SearchHit hit : hits) {// 3.得到_source,也就是原始json文檔String source = hit.getSourceAsString();// 4.反序列化并打印User user = JSONUtil.toBean(source, User.class);result.add(user);}return result;}@ApiOperation("復合條件")@GetMapping("/compare")public List<User> compareQuery(@ApiParam(value = "索引",required = true)@RequestParam("index") String index,@ApiParam(value = "名稱",required = true)@RequestParam ("name")String name,@ApiParam(value = "性別",required = true)@RequestParam("sex") String sex,@ApiParam(value = "年齡",required = true)@RequestParam("age") String age)throws IOException {// 1.創建RequestSearchRequest request = new SearchRequest(index);// 2.組織請求參數// 2.1.準備bool查詢BoolQueryBuilder bool = QueryBuilders.boolQuery();// 2.2.關鍵字搜索if (name!=null){bool.must(QueryBuilders.matchQuery("name", name));}if (sex!=null){// 2.3.品牌過濾bool.filter(QueryBuilders.termQuery("sex", sex));}// 2.4.價格過濾  gt >if (age!=null){bool.filter(QueryBuilders.rangeQuery("age").gt(age));}request.source().query(bool);// 3.發送請求SearchResponse response = client.search(request, RequestOptions.DEFAULT);// 4.解析響應return handleResponse(response);}@ApiOperation("區間查詢")@GetMapping("/term")//termpublic List<User> rangeQuery(@ApiParam(value = "索引",required = true)@RequestParam String index,@ApiParam(value = "左區間",required = true)@RequestParam("gt") String gt,@ApiParam(value = "右區間",required = true)@RequestParam("lt") String lt,@ApiParam(value = "支持排序的字段",required = true)@RequestParam("field") String field) throws IOException {//創建requestSearchRequest request = new SearchRequest(index);//請求參數//todo 健壯性request.source().query(QueryBuilders.rangeQuery(field).gte(gt).lte(lt));//解析相應SearchResponse response = client.search(request, RequestOptions.DEFAULT);return handleResponse(response);}@ApiOperation("多條件查詢")@GetMapping("/multi_match")//multi_match todo 待探討public List<User> multi_matchQuery(@ApiParam(value = "包含條件1" ,required = true)@RequestParam("name1") String args1,@ApiParam(value = "包含條件2",required = true)@RequestParam("name2") String args2) throws IOException {//創建requestSearchRequest request = new SearchRequest("user");//請求參數request.source().query(QueryBuilders.multiMatchQuery("name",args1,args2));//解析相應SearchResponse response = client.search(request, RequestOptions.DEFAULT);return handleResponse(response);}@ApiOperation("match查詢")@GetMapping("/match")//match okpublic List<User> matchQuery(@ApiParam(value = "索引",name = "index",required = true) @RequestParam("index")String index,@ApiParam(value ="匹配字段",name = "field",required = true)@RequestParam("field") String field) throws IOException {//創建requestSearchRequest request = new SearchRequest(index);//請求參數request.source().query(QueryBuilders.matchQuery("name",field));//解析相應SearchResponse response = client.search(request, RequestOptions.DEFAULT);return handleResponse(response);}@ApiOperation("match-all查詢")@GetMapping("/match-all")//match-all okpublic List<User> SearchMatchAll(@ApiParam(value = "索引",name = "index",required = true) @RequestParam("index")String index) throws IOException {//創建requestSearchRequest request = new SearchRequest(index);//請求參數request.source().query(QueryBuilders.matchAllQuery());//解析相應SearchResponse response = client.search(request, RequestOptions.DEFAULT);return handleResponse(response);}
}
Bean
package com.orchids.elasticsearch.web.config;import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** @ Author qwh* @ Date 2024/7/12 21:16*/
@Configuration
public class RestClientConfiguration {@Beanpublic RestHighLevelClient restHighLevelClient(){return new RestHighLevelClient(RestClient.builder(HttpHost.create("http://localhost:9200")));}
}
po
package com.orchids.elasticsearch.web.po;import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;import java.io.Serializable;/*** @ Author qwh* @ Date 2024/7/12 20:20*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@ApiModel(description = "索引庫實體")
public class User implements Serializable {@ApiModelProperty(value = "名字",name = "name",example = "二哈")
//    @NonNullprivate String name;
//    @NonNull@ApiModelProperty(value = "年齡",name = "age",example = "99")private Integer age;
//    @NonNull@ApiModelProperty(value = "性別",name = "sex",example = "男")private String sex;}
app
package com.orchids.elasticsearch;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class ElasticsearchApplication {public static void main(String[] args) {SpringApplication.run(ElasticsearchApplication.class, args);}}
配置類

server:port: 8080
logging:level:web: infopattern:dateformat: HH:mm:ss:SSSfile:path: "logs"
knife4j:enable: trueopenapi:title: 接口文檔description: "接口文檔"email: 123123i@123.cnconcat: erhaurl: https://www.orchids.loveversion: v1.0.0group:default:group-name: defaultapi-rule: packageapi-rule-resources: com.orchids.elasticsearch.web
依賴
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.orchids</groupId><artifactId>elasticsearch</artifactId><version>0.0.1-SNAPSHOT</version><name>elasticsearch</name><description>elasticsearch</description><properties><java.version>1.8</java.version><elasticsearch.version>7.12.1</elasticsearch.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.7.12</spring-boot.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>${elasticsearch.version}</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-client</artifactId><version>${elasticsearch.version}</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>${elasticsearch.version}</version></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><dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-openapi2-spring-boot-starter</artifactId><version>4.1.0</version></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-json</artifactId><version>5.8.28</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.6</version></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring-boot.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><mainClass>com.orchids.elasticsearch.ElasticsearchApplication</mainClass><skip>true</skip></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build></project>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/44844.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/44844.shtml
英文地址,請注明出處:http://en.pswp.cn/web/44844.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

探索JT808協議在車輛遠程視頻監控系統中的應用

一、部標JT808協議概述 隨著物聯網技術的迅猛發展&#xff0c;智能交通系統&#xff08;ITS&#xff09;已成為現代交通領域的重要組成部分。其中&#xff0c;車輛遠程監控與管理技術作為ITS的核心技術之一&#xff0c;對于提升交通管理效率、保障道路安全具有重要意義。 JT8…

TensorBoard ,PIL 和 OpenCV 在深度學習中的應用

重要工具介紹 TensorBoard&#xff1a; 是一個TensorFlow提供的強大工具&#xff0c;用于可視化和理解深度學習模型的訓練過程和結果。下面我將介紹TensorBoard的相關知識和使用方法。 TensorBoard 簡介 TensorBoard是TensorFlow提供的一個可視化工具&#xff0c;用于&#x…

尚品匯-(十七)

目錄&#xff1a; &#xff08;1&#xff09;獲取價格信息 &#xff08;2&#xff09;獲取銷售信息 前面的表&#xff1a; &#xff08;1&#xff09;獲取價格信息 繼續編寫接口&#xff1a;ManagerService /*** 獲取sku價格* param skuId* return*/ BigDecimal getSkuPrice…

『 Linux 』匿名管道應用 - 簡易進程池

文章目錄 池化技術進程池框架及基本思路進程的描述組織管道通信建立的潛在問題 任務的描述與組織子進程讀取管道信息控制子進程進程退出及資源回收 池化技術 池化技術是一種編程技巧,一般用于優化資源的分配與復用; 當一種資源需要被使用時這意味著這個資源可能會被進行多次使…

mqtt.fx連接阿里云

本文主要是記述一下如何使用mqtt.fx連接在阿里云上創建好的MQTT服務。 1 根據MQTT填寫對應端口即可 找到設備信息&#xff0c;里面有MQTT連接參數 2 使用物模型通信Topic&#xff0c;注意這里的post說設備上報&#xff0c;那也就是意味著云端訂閱post&#xff1b;set則意味著設…

【輕松拿捏】Java-final關鍵字(面試)

目錄 1. 定義和基本用法 回答要點&#xff1a; 示例回答&#xff1a; 2. final 變量 回答要點&#xff1a; 示例回答&#xff1a; 3. final 方法 回答要點&#xff1a; 示例回答&#xff1a; 4. final 類 回答要點&#xff1a; 示例回答&#xff1a; 5. final 關鍵…

搭建hadoop+spark完全分布式集群環境

目錄 一、集群規劃 二、更改主機名 三、建立主機名和ip的映射 四、關閉防火墻(master,slave1,slave2) 五、配置ssh免密碼登錄 六、安裝JDK 七、hadoop之hdfs安裝與配置 1)解壓Hadoop 2)修改hadoop-env.sh 3)修改 core-site.xml 4)修改hdfs-site.xml 5) 修改s…

【進階篇-Day9:JAVA中單列集合Collection、List、ArrayList、LinkedList的介紹】

目錄 1、集合的介紹1.1 概念1.2 集合的分類 2、單列集合&#xff1a;Collection2.1 Collection的使用2.2 集合的通用遍歷方式2.2.1 迭代器遍歷&#xff1a;&#xff08;1&#xff09;例子&#xff1a;&#xff08;2&#xff09;迭代器遍歷的原理&#xff1a;&#xff08;3&…

排序——交換排序

在上篇文章我們詳細介紹了排序的概念與插入排序&#xff0c;大家可以通過下面這個鏈接去看&#xff1a; 排序的概念及插入排序 這篇文章就介紹一下一種排序方式&#xff1a;交換排序。 一&#xff0c;交換排序 基本思想&#xff1a;兩兩比較&#xff0c;如果發生逆序則交換…

jenkins系列-09.jpom構建java docker harbor

本地先啟動jpom server agent: /Users/jelex/Documents/work/jpom-2.10.40/server-2.10.40-release/bin jelexjelexxudeMacBook-Pro bin % sh Server.sh start/Users/jelex/Documents/work/jpom-2.10.40/agent-2.10.40-release/bin jelexjelexxudeMacBook-Pro bin % ./Agent.…

達夢數據庫的系統視圖v$sessions

達夢數據庫的系統視圖v$sessions 達夢數據庫&#xff08;DM Database&#xff09;是中國的一款國產數據庫管理系統&#xff0c;它提供了類似于Oracle的系統視圖來監控和管理數據庫。V$SESSIONS 是達夢數據庫中的一個系統視圖&#xff0c;用于顯示當前數據庫會話的信息。 以下…

全自主巡航無人機項目思路:STM32/PX4 + ROS + AI 實現從傳感融合到智能規劃的端到端解決方案

1. 項目概述 本項目旨在設計并實現一款高度自主的自動巡航無人機系統。該系統能夠按照預設路徑自主飛行&#xff0c;完成各種巡航任務&#xff0c;如電力巡線、森林防火、邊境巡邏和災害監測等。 1.1 系統特點 基于STM32F4和PX4的高性能嵌入式飛控系統多傳感器融合技術實現精…

MYSQL--第八次作業

MYSQL–第八次作業 一、備份與恢復 環境搭建&#xff1a; CREATE DATABASE booksDB; use booksDB;CREATE TABLE books ( bk_id INT NOT NULL PRIMARY KEY, bk_title VARCHAR(50) NOT NULL, copyright YEAR NOT NULL );CREATE TABLE authors ( auth_id INT NOT NULL PRI…

geoServer在windows中下載安裝部署詳細操作教程

這里寫目錄標題 1.安裝環境檢查2.下載安裝包&#xff08;1&#xff09;進入下載地址&#xff1a;&#xff08;2&#xff09;以下載最新版為例&#xff0c;點擊“Stable GeoServer”下載&#xff08;3&#xff09;安裝有兩種方式&#xff08;4&#xff09;我這里選擇下載war包 3…

python作業三

1.使用requests模塊獲取這個json文件http://java-api.super-yx.com/html/hello.json 2.將獲取到的json轉為dict 3.將dict保存為hello.json文件 4.用io流寫一個copy(src,dst)函數,復制hello.json到C:\hello.json import json import shutilimport requests #使用requests模塊獲…

Qt MV架構-視圖類

一、基本概念 在MV架構中&#xff0c;視圖包含了模型中的數據項&#xff0c;并將它們呈現給用戶。數據項的表示方法&#xff0c;可能和數據項在存儲時用的數據結構完全不同。 這種內容與表現分離之所以能夠實現&#xff0c;是因為使用了 QAbstractItemModel提供的一個標準模…

`nmap`模塊是一個用于與Nmap安全掃描器交互的庫

在Python中&#xff0c;nmap模塊是一個用于與Nmap安全掃描器交互的庫。Nmap&#xff08;Network Mapper&#xff09;是一個開源工具&#xff0c;用于發現網絡上的設備和服務。雖然Python的nmap模塊可能不是官方的Nmap庫&#xff08;因為Nmap本身是用C/C編寫的&#xff09;&…

基于JavaSpringBoot+Vue+uniapp微信小程序校園宿舍管理系統設計與實現

基于JavaSpringBootVueuniapp微信小程序實現校園宿舍管理系統設計與實現 目錄 第一章 緒論 1.1 研究背景 1.2 研究現狀 1.3 研究內容 第二章 相關技術介紹 2.1 Java語言 2.2 HTML網頁技術 2.3 MySQL數據庫 2.4 Springboot 框架介紹 2.5 VueJS介紹 2.6 ElementUI介紹…

視頻轉換、提取音頻、視頻加水印、視頻去水印、音頻轉換、分割合并壓縮等,批量還幾乎免費

「想轉就轉視頻音頻助手」免費版來襲&#xff01; 在數字化時代&#xff0c;視頻和音頻處理已成為我們日常生活的一部分。無論是制作個人視頻博客、編輯家庭影片&#xff0c;還是處理音頻文件&#xff0c;我們都在尋找一個強大而易于使用的解決方案。今天&#xff0c;我要向您…

基于大語言模型(LLM)的合成數據生成、策展和評估的綜述

節前&#xff0c;我們星球組織了一場算法崗技術&面試討論會&#xff0c;邀請了一些互聯網大廠朋友、參加社招和校招面試的同學。 針對算法崗技術趨勢、大模型落地項目經驗分享、新手如何入門算法崗、該如何準備、面試常考點分享等熱門話題進行了深入的討論。 合集&#x…