通过java代码实现ES中的常用搜索

news2025/1/24 18:02:48

目录

测试环境准备

在指定索引下搜索全部(可以指定字段)

通过ids进行搜索

对搜索结果进行分页

match分词搜索

不分词模糊搜索:wildcardQuery与matchPhraseQuery

term 搜索(精确匹配)

multi_match搜索

bool搜索 多条件匹配

filter过滤搜索

sort排序搜索

后续待补充:queryStringQuery,minimumShouldMatch,对检索结果中的关键词进行高亮


测试环境准备

测试环境:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <version>2.0.6.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <version>2.0.6.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>7.3.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>7.3.0</version>
</dependency>

2配置 application.yml

spring:
  application:
    name: service-search
eslearn:
  elasticsearch:
    hostlist: 127.0.0.1:9200 #多个结点中间用逗号分隔

 3主类代码

@SpringBootApplication
public class SearchApplication {
    public static void main(String[] args) {
        SpringApplication.run(SearchApplication.class,args);
    }
}

配置类:

package com.learn.es.cofig;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author LJM
 * @create 2022/12/10
 */
@Configuration
public class ElasticSearchConfig {
    
    @Value("${eslearn.elasticsearch.hostlist}")
    private String hostList;
    
    @Bean(destroyMethod = "close") //表示连接使用完成后需要关闭
    public RestHighLevelClient restHighLevelClient(){
        String[] split = hostList.split(",");
        //这种写法是考虑到可能会配置多个es节点
        HttpHost[] httpHosts = new HttpHost[split.length];
        for (int i = 0; i < split.length; i++) {
            String item = split[i];
            httpHosts[i] = new HttpHost(item.split(":")[0],Integer.parseInt(item.split(":")[1]),"http");
        }

        return new RestHighLevelClient(RestClient.builder(httpHosts));
    }
    
}

测试项目结构:

 在kibana中把数据插入es中:

delete book   //先删除索引

PUT /book    //往索引中插入数据进行测试,后面在api实现搜索的小节,可以使用从数据库中读取数据 然后把数据插入es库指定的索引

PUT /book/_doc/1
{
"name": "Bootstrap开发",
"description": "Bootstrap是由Twitter推出的一个前台页面开发css框架,是一个非常流行的开发框架,此框架集成了多种页面效果。此开发框架包含了大量的CSS、JS程序代码,可以帮助开发者(尤其是不擅长css页面开发的程序人员)轻松的实现一个css,不受浏览器限制的精美界面css效果。",
"studymodel": "201002",
"price":38.6,
"timestamp":"2019-08-25 19:11:35",
"pic":"group1/M00/00/00/wKhlQFs6RCeAY0pHAAJx5ZjNDEM428.jpg",
"tags": [ "bootstrap", "dev"]
}


PUT /book/_doc/2
{
"name": "java编程思想",
"description": "java语言是世界第一编程语言,在软件开发领域使用人数最多。",
"studymodel": "201001",
"price":68.6,
"timestamp":"2019-08-25 19:11:35",
"pic":"group1/M00/00/00/wKhlQFs6RCeAY0pHAAJx5ZjNDEM428.jpg",
"tags": [ "java", "dev"]
}




PUT /book/_doc/3
{
"name": "spring开发基础",
"description": "spring 在java领域非常流行,java程序员都在用。",
"studymodel": "201001",
"price":88.6,
"timestamp":"2019-08-24 19:11:35",
"pic":"group1/M00/00/00/wKhlQFs6RCeAY0pHAAJx5ZjNDEM428.jpg",
"tags": [ "spring", "java"]
}

测试类代码结构: 

/**
 * @author LJM
 * @create 2022/12/13
 * 测试使用java代码实现es的各种搜索
 */
@SpringBootTest(classes = SearchApplication.class)
@RunWith(SpringRunner.class)
public class TestSearch {
    @Autowired
    RestHighLevelClient client;

// 后面的测试方法会全部写在这个类中 .....

}

在指定索引下搜索全部(可以指定字段)

在kibana中 GET /book/_search 先获取一下本地es库中的book索引下有多少数据。

/**
     *     搜索全部
     *       GET book/_search
     *       {
     *         "query": {
     *          "match_all": {}
     *          }
     *       }
     * @throws IOException
     */
    @Test
    public void testSearchAll() throws IOException {

        //1构建搜索请求  实际生产环境中这个索引名称的获取:①把这个索引名称写在枚举类中,然后从枚举类中获取②从配置文件中获取
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.matchAllQuery());

        //获取某些字段
        searchSourceBuilder.fetchSource(new String[]{"name"}, new String[]{});

        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("score:" + score);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

通过ids进行搜索

 /**
     * 通过ids进行搜索  有的就查询出来,没有的也不会报错
     *     GET /book/_search
     *     {
     *         "query": {
     *            "ids" : {
     *              "values" : ["1", "2", "6"]
     *              }
     *         }
     *     }
     * @throws IOException
     */
    @Test
    public void testSearchIds() throws IOException {

        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.idsQuery().addIds("1","2","6"));

        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

对搜索结果进行分页

    /**
     *     对搜索结果进行分页
     *         GET book/_search
     *         {
     *             "query": {
     *               "match_all": {}
     *            },
     *             "from": 0,
     *             "size": 2
     *         }
     */
    @Test
    public void testSearchPage() throws IOException {
        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.matchAllQuery());

        //搜索第几页的数据
        int page=1;
        //每页展示几个数据
        //int size=2;  //因为本地es一共就插入了三条数据进行测试,所以可以把大小分别设置为2和3看一下输出效果
        int size=3;
        //下标计算
        int from = (page-1) / size;

        searchSourceBuilder.from(from);
        searchSourceBuilder.size(size);

        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

match分词搜索

 /**
     * match搜索  这个是会进行分词搜索的
     *     GET /book/_search
     *     {
     *         "query": {
     *            "match": {
     *             "description": "java程序员"
     *         }
     *       }
     *     }
     * @throws IOException
     */
    @Test
    public void testSearchMatch() throws IOException {
        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.matchQuery("description", "java程序员"));


        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

不分词模糊搜索:wildcardQuery与matchPhraseQuery

    /**
     * 不分词模糊搜索   like '%检索词%'
     * @throws IOException
     */
    @Test
    public void testSearchLike() throws IOException {
        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        //使用matchPhraseQuery 需要对检索的关键词的前后加 * 否则不是完全的模糊匹配  可以对检索的结果中的检索关键词进行高亮
        searchSourceBuilder.query(QueryBuilders.matchPhraseQuery("description", "*"+"程序员"+"*"));

        //还可以使用wildcardQuery 但是这种就会导致检索的结果不能高亮(这个不太确定,但是我自己试的时候,这样确实是不能对检索结果中的检索词进行高亮)
        //需要在检索的字段名后拼接 ".keyword"  并且也需要对检索词前后添加 *
//        searchSourceBuilder.query(QueryBuilders.wildcardQuery("description"+".keyword","*"+"程序员"+"*"));



        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

term 搜索(精确匹配)

 /**
     * term 搜索  如果字段为keyword那么【存储】和【搜索】都不分词。 搜索的时候相当于在使用 = 符号进行搜索
     *        GET / book / _search
     *         {
     *             "query":{
     *                 "term":{
     *                     "description":"java程序员"
     *                 }
     *             }
     *         }
     * @throws IOException
     */
    @Test
    public void testSearchTerm() throws IOException {

        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        //如果字段的映射是text但是也想要精确匹配,可以这样操作:QueryBuilders.termQuery("description" + ".keyword","java程序员")
        searchSourceBuilder.query(QueryBuilders.termQuery("description", "java语言"));

        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

multi_match搜索

    /**
     * multi_match搜索
     *     GET /book/_search
     *     {
     *         "query": {
     *           "multi_match": {
     *             "query": "java程序员",
     *             "fields": ["name", "description"]
     *         }
     *       }
     *     }
     * @throws IOException
     */
    @Test
    public void testSearchMultiMatch() throws IOException {

        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        //第二个参数才是 字段  第一个参数是匹配的内容
        searchSourceBuilder.query(QueryBuilders.multiMatchQuery("java程序员","name","description"));

        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

bool搜索 多条件匹配

    /**
     * bool搜索 多条件匹配  and or !=
     *         GET / book / _search
     *         {
     *          "query":{
     *             "bool":{
     *                 "must": [
     *                 {
     *                     "multi_match":{
     *                     "query":"java程序员",
     *                             "fields": ["name", "description"]
     *                     }
     *                 }
     *                 ],
     *                 "should": [
     *                     {
     *                         "match":{
     *                         "studymodel":"201001"
     *                     }
     *                 }
     *                 ]
     *             }
     *         }
     *       }
     * @throws IOException
     */
    @Test
    public void testSearchBool() throws IOException {

        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

        //构建multiMatch请求 第一个参数是检索内容 第二个参数是检索的字段
        MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery("java程序员", "name", "description");
        //构建match请求
        MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("name", "测试没有的字段");

        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
        boolQueryBuilder.must(multiMatchQueryBuilder);
        boolQueryBuilder.should(matchQueryBuilder);
        //        boolQueryBuilder.must(matchQueryBuilder); //把should改成must就相当于用 and进行了再一次的过滤 就会查询不到数据

        searchSourceBuilder.query(boolQueryBuilder);
        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

}

filter过滤搜索

过滤搜索和范围搜索的区别:

filter,仅仅只是按照搜索条件过滤出需要的数据而已,不计算任何相关度分数,对相关度没有任何影响。

query,会去计算每个document相对于搜索条件的相关度,并按照相关度进行排序。

    /**
     * filter过滤搜索
     *     GET /book/_search
     *     {
     *         "query": {
     *           "bool": {
     *             "must": [
     *             {
     *                 "multi_match": {
     *                 "query": "java程序员",
     *                         "fields": ["name","description"]
     *                                      }
     *             }
     *       ],
     *             "should": [
     *             {
     *                 "match": {
     *                 "studymodel": "201001"
     *             }
     *             }
     *           ],
     *             "filter": {
     *                 "range": {
     *                     "price": {
     *                         "gte": 50,
     *                          "lte": 90
     *                     }
     *                 }
     *
     *             }
     *         }
     *     }
     *  }
     * @throws IOException
     */
    @Test
    public void testSearchFilter() throws IOException {

        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

        //构建multiMatch请求
        MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery("java程序员", "name", "description");
        //构建match请求
        MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("studymodel", "201001");

        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
        boolQueryBuilder.must(multiMatchQueryBuilder);
        boolQueryBuilder.should(matchQueryBuilder);

        boolQueryBuilder.filter(QueryBuilders.rangeQuery("price").gte(50).lte(90));

        searchSourceBuilder.query(boolQueryBuilder);

        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");

        }
    }

sort排序搜索

    /**
     * sort排序搜索
     *     GET /book/_search
     *     {
     *         "query": {
     *         "bool": {
     *             "must": [
     *             {
     *                 "multi_match": {
     *                 "query": "java程序员",
     *                         "fields": ["name","description"]
     *             }
     *             }
     *       ],
     *             "should": [
     *             {
     *                 "match": {
     *                 "studymodel": "201001"
     *             }
     *             }
     *       ],
     *             "filter": {
     *                 "range": {
     *                     "price": {
     *                         "gte": 50,
     *                                 "lte": 90
     *                     }
     *                 }
     *
     *             }
     *         }
     *     },
     *         "sort": [
     *         {
     *             "price": {
     *             "order": "asc"
     *         }
     *         }
     *   ]
     *     }
     * @throws IOException
     */
    @Test
    public void testSearchSort() throws IOException {

        //1构建搜索请求
        SearchRequest searchRequest = new SearchRequest("book");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

        //构建multiMatch请求
        MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery("java程序员", "name", "description");
        //构建match请求
        MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("studymodel", "201001");

        BoolQueryBuilder boolQueryBuilder=QueryBuilders.boolQuery();
        boolQueryBuilder.must(multiMatchQueryBuilder);
        boolQueryBuilder.should(matchQueryBuilder);

        boolQueryBuilder.filter(QueryBuilders.rangeQuery("price").gte(50).lte(90));

        searchSourceBuilder.query(boolQueryBuilder);

        //按照价格升序
        searchSourceBuilder.sort("price", SortOrder.ASC);


        searchRequest.source(searchSourceBuilder);

        //2执行搜索
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        //3获取结果
        SearchHits hits = searchResponse.getHits();

        //数据数据
        SearchHit[] searchHits = hits.getHits();
        System.out.println("--------------------------");
        for (SearchHit hit : searchHits) {
            String id = hit.getId();
            float score = hit.getScore();
            //这个source里面就是我们存储的数据
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            String name = (String) sourceAsMap.get("name");
            String description = (String) sourceAsMap.get("description");
            Double price = (Double) sourceAsMap.get("price");
            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("description:" + description);
            System.out.println("price:" + price);
            System.out.println("==========================");
        }
    }

后续待补充:queryStringQuery,minimumShouldMatch,对检索结果中的关键词进行高亮

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/92071.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

23年如何准备考PMP?这4点建议你得看

23年的PMP考试还有3个多月&#xff0c;现在开始备考&#xff0c;再合适不过&#xff0c;我这里提出四点备考建议&#xff0c;希望能帮到备考的大家&#xff1a; 【《PMBOK指南》】 PMP的教材仍是第六版&#xff0c;如果有第七版就看第七版&#xff0c;纸质或者电子版都可以&am…

【基础强训】day1

一、选择题&#xff1a; 1. 以下for循环的执行次数是&#xff08;&#xff09; for(int x 0, y 0; (y 123) && (x < 4); x); A 是无限循环 B 循环次数不定 C 4次 D 3次 C y123为真&#xff0c;所以就循环四次。 2. 以下程序的运行结果是&#xff08;&#xff…

jsp+ssm计算机毕业设计ssm酒店综合管理平台【附源码】

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; JSPSSM mybatis Maven等等组成&#xff0c;B/S模式 Mave…

2D激光雷达:使用MindStudio进行MindX SDK任务开发

任务介绍 该项目基于DROW3和DR-SPAAM模型&#xff0c;实现了实时的2D激光雷达行人检测。 主要处理流程为&#xff1a;输入预处理后的激光雷达点云序列&#xff08;帧&#xff09;->行人检测模型推理->行人检测模型后处理->检测结果输出及可视化。 由于二维距离数据信…

Unity Gradient Lerp 颜色渐变

最近改插件&#xff0c;本来如果有Gradient的lerp方法&#xff0c;改起来会非常方便。因为插件的更改入口是这个Gradient。运行时候手动调节inspector面板可以直接更改效果。那么此时只要在代码中更改Gradient即可。 但是找了几遍Color&#xff0c;ColorUtility&#xff0c;Gr…

怎么去图片水印?三招让你快速学会图片去水印

上大学的时候&#xff0c;老师让我们每人写一个关于“阅读”的主题报告。写这个主题报告的时候&#xff0c;我发现在网上找的图片素材大多带有水印&#xff0c;十分影响报告的展示效果。于是&#xff0c;我就上网找了一些怎么去图片水印的方法&#xff0c;对这些方法进行试验后…

Redis持久化(RDBAOF)

持久化简介&#xff1a; 不知道大家有没有遇见过&#xff0c;就是正工作的时候停电了&#xff0c;如果你用的是笔记本电脑还好&#xff0c;你有电池&#xff0c;但如果你用的是台式机呢&#xff0c;那恐怕就比较灾难了&#xff0c;假如你现在正在写一个比较重要的文档&#xf…

Java集合——Map

Map集合 Map用于保存具有映射关系的数据&#xff0c;以键值对的形式存储&#xff0c;支持通过key来访问value&#xff0c;因此key不能重复。 Map接口下主要有Hashtable、HashMap、LinkedHashMap、ConcurrentHashMap 四个主要的实现类&#xff0c;实现的基本原理类似&#xff0…

【图像处理】Hough变换检测直线与圆的原理

霍夫变换的基本原理 霍夫变换(Hough Transform)可以理解为图像处理中的一种特征提取技术&#xff0c;通过投票算法检测具有特定形状的物体。霍夫变换运用两个坐标空间之间的变换将在一个空间中具有相同形状的曲线或直线映射到另一个坐标空间中的一个点形成峰值&#xff0c;从而…

菜菜学paddle第七篇:目标检测的基本概念

一、什么是目标检测&#xff1f; 在前面的几篇中&#xff0c;我们学习了使用卷积神经网络进行图像分类&#xff0c;比如手写数字识别是用来识别0~9这十个数字。与图像分类处理单个物体的识别不同&#xff0c;目标检测它识别的不仅是物体&#xff0c;还是多个物体&#xff0c;…

[附源码]Python计算机毕业设计高校教务管理系统Django(程序+LW)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程 项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等…

Spring之IOC

IoC&#xff08;Inverse of Control:控制反转&#xff09;是一种设计思想&#xff0c;就是 将原本在程序中手动创建对象的控制权&#xff0c;交由Spring框架来管理。 IoC 在其他语言中也有应用&#xff0c;并非 Spirng 特有。 IoC 容器是 Spring 用来实现 IoC 的载体&#xff0…

服务攻防-应用协议RsyncSSHRDPFTP漏洞批扫口令猜解

目录 测试思路 &#xff08;一&#xff09;口令猜解——SSH&RDP&FTP Demo: &#xff08;二&#xff09;配置不当-未授权访问-Rsync 文件备份 尝试读取src文件 &#xff08;三&#xff09;协议漏洞-应用软件-FTP&Proftpd 搭建 &#xff08;四&#xff09;协议漏…

音视频- iOS使用metal渲染图像(一)

概要 本文主要总结一下Metal的基本使用&#xff0c;用来渲染拍照的到的图像&#xff0c;其中涉及到的有UIKit中的MTKView&#xff0c;Metal中负责渲染的几个类&#xff0c;使用MSL&#xff08;Metal Shading Language&#xff09;编写着色器&#xff0c;最终将图片渲染出来…

Python 绘制极坐标图(玫瑰花图优化)

风速的玫瑰花图可见 Matlab 绘制风速、风向统计玫瑰花图 在今天的这边博文,选用Python工具,绘制玫瑰花图,并对图进行优化。 example 1 【不规则宽度】N = 20 theta = np.linspace(0.0,2*np.pi,N,endpoint=False)

Jmeter(十五):jmeter场景的运行方式(GUI运行和命令行运行)命令行相关参数

jmeter场景的运行方式(GUI运行和命令行运行) 运行方式&#xff1a; GUI运行&#xff1a;通过图形界面方式运行&#xff0c;该运行方式的可视化界面及监听器动态展示 结果都比较消耗负载机资源&#xff0c;建议大并发时不用&#xff0c;一般进行脚本调试&#xff1b; 命令行运…

【PTA-训练day17】L2-029 特立独行的幸福 + L1-071 前世档案

L2-029 特立独行的幸福 - 递归/模拟 判断素数 PTA | 程序设计类实验辅助教学平台 思路&#xff1a; 第一层循环是边界循环 for(int il;i<r;i)枚举每一个i 第二层循环是判断这个i是不是幸福数st数组 判定 i 这个数在迭代过程中是否出现循环 如果出现循环及时跳出比如&…

【TypeScript系列】【一篇就够】TypeScript知识点总结(二)

12 面向对象简介 简而言之&#xff0c;面向对象就是程序之中所有的操作都需要通过对象来完成。 举例来说&#xff0c; 操作浏览器要使用windows对象&#xff1b;操作网页要使用document对象&#xff1b;操作控制台要使用console对象。一切操作都要通过对象&#xff0c;也就是…

nacos--扩展--03--系统参数

nacos–扩展–03–系统参数 1、Nacos Server 配置参数位置&#xff1a;{nacos.home}/conf/application.properties里注意&#xff1a;如果参数名后标注了(-D)的&#xff0c;则表示是 JVM 的参数&#xff0c;需要在{nacos.home}/bin/startup.sh里进行相应的设置。 案例&#xf…

测试用例等级怎么划分?别再傻傻的一脸懵逼

我们都知道测试工程师最基本的能力便是编写测试用例&#xff0c;可是看似简单的用例&#xff0c;后面其实蕴含这个很多人忽略的细节&#xff0c;今天就来说测试里面所蕴含的很多细节。 很多时候不只是测试和测试用例息息相关&#xff0c;开发&#xff0c;产品也有的时候对于测试…