国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch

這篇具有很好參考價值的文章主要介紹了Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

ES概述

Elasticsearch,簡稱為es,es是一個開源的高擴(kuò)展的分布式全文檢索引擎,它可以近乎實時的存儲、檢索數(shù)據(jù);本身擴(kuò)展性很好,可以擴(kuò)展到上百臺服務(wù)器,處理PB級別(大數(shù)據(jù)時代)的數(shù)據(jù)。es也使用Java開發(fā)并使用Lucene作為其核心來實現(xiàn)所有索引和搜索的功能,但是它的目的是通過簡單的RESTful API來隱藏Lucene的復(fù)雜性,從而讓全文搜索變得簡單。
據(jù)國際權(quán)威的數(shù)據(jù)庫產(chǎn)品評測機(jī)構(gòu)DB Engines的統(tǒng)計,在2016年1月,ElasticSearch已超過Solr等,成為排名第一的搜索引擎類應(yīng)用。

ES簡介

Elasticsearch簡介
Elasticsearch是一個實時分布式搜索和分析引擎。它讓你以前所未有的速度處理大數(shù)據(jù)成為可能。它用于全文搜索、結(jié)構(gòu)化搜索、分析以及將這三者混合使用∶
維基百科使用Elasticsearch提供全文搜索并高亮關(guān)鍵字,以及輸入實時搜索(search-asyou-type)和搜索糾錯(did-you-mean)等搜索建議功能。
英國衛(wèi)報使用Elasticsearch結(jié)合用戶日志和社交網(wǎng)絡(luò)數(shù)據(jù)提供給他們的編輯以實時的反饋,以便及時了解公眾對新發(fā)表的文章的回
應(yīng)
StackOverflow結(jié)合全文搜索與地理位置查詢,以及more-like-this功能來找到相關(guān)的問題和答案。 Github使用Elasticsearch檢索1300億行的代碼。
但是Elasticsearch不僅用于大型企業(yè),它還讓像DataDog以及Klout這樣的創(chuàng)業(yè)公司將最初的想法變成可擴(kuò)展的解決方案。 Elasticsearch可以在你的筆記本上運行,也可以在數(shù)以百計的服務(wù)器上處理PB級別的數(shù)據(jù)。
Elasticsearch是一個基于Apache Lucene(TM)的開源搜索引擎。無論在開源還是專有領(lǐng)域,Lucene可以被認(rèn)為是迄今為止最先進(jìn)、性能最好的、功能最全的搜索引擎庫。
但是,Lucene只是一個庫。想要使用它,你必須使用Java來作為開發(fā)語言并將其直接集成到你的應(yīng)用中,更糟糕的是,Lucene非常復(fù)雜,你需要深入了解檢索的相關(guān)知識來理解它是如何工作的。
Elasticsearch也使用Java開發(fā)并使用Lucene作為其核心來實現(xiàn)所有索引和搜索的功能,但是它的目的是通過簡單的 RESTful API來隱藏Lucene的復(fù)雜性,從而讓全文搜索變得簡單。

LUCENE簡介

Lucene是apache軟件基金會4 jakarta項目組的一個子項目,是一個開放源代碼的全文檢索引擎工具包,但它不是一個完整的全文檢索引擎,而是一個全文檢索引擎的架構(gòu),提供了完整的查詢引擎和索引擎,部分文本分析引擎(英文與德文兩種西方語言)。 Lucene的目的是為軟件開發(fā)人員提供一個簡單易用的工具包,以方便的在目標(biāo)系統(tǒng)中實現(xiàn)全文檢索的功能,或者是以此為基礎(chǔ)建立起完整的全文檢索引擎。Lucene是一套用于全文檢索和搜尋的開源程式庫,由Apache軟件基金會支持和提供。Lucene提供了一個簡單卻強(qiáng)大的應(yīng)用程式接口,能夠做全文索引和搜尋。在Java開發(fā)環(huán)境里L(fēng)ucene是一個成熟的免費開源工具。就其本身而言 , Lucene是當(dāng)前以及最近幾年最受歡迎的免費Java信息檢索程序庫。人們經(jīng)常提到信息檢索程序庫,雖然與搜索引擎有關(guān),但不應(yīng)該將信息檢索程序庫與搜索引擎相混淆。
Lucene是一個全文檢索引擎的架構(gòu)。那什么是全文搜索引擎 ?
全文搜索引擎是名副其實的搜索引擎,國外具代表性的有Google、Fast/AlITheWeb、AltaVista、Inktomi、Teoma、WiseNut等,國內(nèi)著名的有百度(Baidu)。它們都是通過從互聯(lián)網(wǎng)上提取的各個網(wǎng)站的信息(以網(wǎng)頁文字為主)而建立的數(shù)據(jù)庫中,檢索與用戶查詢條件匹配的相關(guān)記錄,然后按一定的排列順序?qū)⒔Y(jié)果返回給用戶,因此他們是真正的搜索引擎。
從搜索結(jié)果來源的角度,全文搜索引擎又可細(xì)分為兩種,一種是擁有自己的檢索程序(Indexer),俗稱"蜘蛛"(Spider)程序或"機(jī)器人"(Robot)程序,并自建網(wǎng)頁數(shù)據(jù)庫,搜索結(jié)果直接從自身的數(shù)據(jù)庫中調(diào)用,如上面提到的7家引擎;另一種則是租用其他引擎的數(shù)據(jù)庫,并按自定的格式排列搜索結(jié)果,如Lycos引擎。

ES 和 solr比較

1、es基本是開箱即用(解壓就可以用!), 非常簡單。Solr安裝略微復(fù)雜一丟丟 ! 2、Solr 利用 Zookeeper 進(jìn)行分布式管理,而 Elasticsearch 自身帶有分布式協(xié)調(diào)管理功能。 3、Solr 支持更多格式的數(shù)據(jù),比如SON、XML、CSV,而 Elasticsearch 僅支持json文件格式。
4、Solr 官方提供的功能更多,而 Elasticsearch 本身更注重于核心功能,高級功能多有第三方插件提供,例如圖形化界面需要 kibana友好支撐~!
5、Solr 查詢快,但更新索引時慢(即插入刪除慢),用于電商等查詢多的應(yīng)用 ;●ES建立索引快(即查詢慢),即實時性查詢快,用于facebook新浪等搜索。
● Solr是傳統(tǒng)搜索應(yīng)用的有力解決方案,但 Elasticsearch 更適用于新興的實時搜索應(yīng)用。
6、Solr比較成熟,有一個更大,更成熟的用戶、開發(fā)和貢獻(xiàn)者社區(qū),而 Elasticsearch相對開發(fā)維護(hù)者較少,更新太快,學(xué)習(xí)使用成本較高。

ES安裝教程

https://blog.csdn.net/qq_40942490/article/details/111594267

IK中文分詞器

安裝IK分詞器之后,可以配置屬于自己的字典,具體目錄在config 中的xml文件中配置
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

ES數(shù)據(jù)結(jié)構(gòu)與mysql的相同之處

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

使用RESTful風(fēng)格接口操作ES

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

使用put命令創(chuàng)建索引(相當(dāng)于數(shù)據(jù)庫)以及數(shù)據(jù),其中test1為索引,type為類型,1為行
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

ES搜索中的數(shù)據(jù)類型

核心數(shù)據(jù)類型
String, byte, short,integer,long,float,double,boolean,date
復(fù)合數(shù)據(jù)類型
Array,Object

使用put命令設(shè)計索引的數(shù)據(jù)類型

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

如果沒有設(shè)置數(shù)據(jù)類型,就會在set值的時候自動設(shè)置數(shù)據(jù)類型
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

獲取有多少索引

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

put命令

使用put命令可以直接覆蓋數(shù)據(jù),其中數(shù)據(jù)完全被覆蓋,以新PUT進(jìn)去的數(shù)據(jù)為主
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
其對應(yīng)的版本號也是會更改的
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

更新命令

使用更新的命令,會根據(jù)字段名更新對應(yīng)的值
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

刪除命令

Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

查詢

準(zhǔn)備數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
執(zhí)行搜索命令
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
執(zhí)行完搜索之后就發(fā)現(xiàn)通過 ‘小米’和‘mix4’都是可以進(jìn)行查詢的 ,然后通過分詞器看看“小米mix4”,發(fā)現(xiàn)這個字符串被分詞為 ‘小米’和‘mix4’,其中英文不分詞
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
因為英文不分詞 通過中文加部分英文(或者部分?jǐn)?shù)字)的方式是不能查詢出來的,而且通過分詞器是可以開到分詞成功的了。(說明,部分英文具體指分詞之后的單詞的一部分,例如 小米mix4 會被分為 ‘小米’+‘mix4’,其中‘m’就是mix4的部分英文)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
條件查詢指定字段 其中match是會使用分詞器進(jìn)行解析的
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
根據(jù)字段排序
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
分頁 使用from和size
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

布爾值查詢

其中 must 相當(dāng)于mysql中的and;
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
should相當(dāng)于mysql中的or;
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
must_not是不等于的意思(例如下面查詢的是name不是小米和desc中沒有買的)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

Filter過濾器

查詢名稱中有小米的產(chǎn)品,且價格范圍在100到2000的
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
多條件查詢,多個條件使用空格或者逗號隔開,只要滿足一個就可以被查詢出來,這個時候可以通過分值進(jìn)行計算,比如找房子,可以根據(jù)多個地區(qū)查找
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

倒排索引!

關(guān)于分詞器

搜索關(guān)鍵字
Match:是會經(jīng)過分詞器解析的
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Term: 是精確查詢,不經(jīng)過分詞器解析
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
數(shù)據(jù)字段類型不同
當(dāng)字段類型是text時,是會經(jīng)過分詞器解析的
當(dāng)字段類型是keyword時,不會經(jīng)過分詞器解析
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
例如我們在設(shè)計索引時,設(shè)置name是關(guān)鍵字,desc是text,則在我們搜索時會出現(xiàn)以下情況
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
高亮查詢
使用highlight關(guān)鍵字,然后指定字段,默認(rèn)樣式是標(biāo)簽
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)
自定義標(biāo)簽,要使用pre_tags和post_tags
Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch,elasticsearch,spring boot,大數(shù)據(jù)

引入依賴

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>

創(chuàng)建配置文件

package com.mu.es.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;

@Configuration
public class ElasticSearchConfig {

    @Bean
    public RestHighLevelClient restHighLevelClient() {
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("127.0.0.1", 9200, "http")
                ));
        return client;
    }

}

測試類文章來源地址http://www.zghlxwxcb.cn/news/detail-804861.html


@SpringBootTest
class ElasticsearchApplicationTests {


    // 注入ES客戶端
    @Autowired
    RestHighLevelClient restHighLevelClient;

    @Test
    void testCreateIndex() throws IOException {
        // 創(chuàng)建索引
        CreateIndexResponse text_index = restHighLevelClient.indices().create(new CreateIndexRequest("text_index"), RequestOptions.DEFAULT);
        System.out.println("text_index = " + text_index);


    }

    @Test
    void test1() throws IOException {
        // 判斷索引是否存在
        GetIndexRequest textIndexGet = new GetIndexRequest("text_index"); // 創(chuàng)建獲得索引的請求
        boolean exists = restHighLevelClient.indices().exists(textIndexGet, RequestOptions.DEFAULT);
        System.out.println("exists = " + exists);
    }


    /**
     * 刪除索引
     *
     * @throws IOException
     */
    @Test
    void test2() throws IOException {
        DeleteIndexRequest de = new DeleteIndexRequest("text_index");// 創(chuàng)建刪除索引的請求
        AcknowledgedResponse response = restHighLevelClient.indices().delete(de, RequestOptions.DEFAULT);
        System.out.println("exists = " + response);
    }

    /**
     * 在索引中添加文檔數(shù)據(jù)
     *
     * @throws IOException
     */
    @Test
    void test3() throws IOException {
        // 準(zhǔn)備數(shù)據(jù)
        User user = new User("mls", 25, "河南");
        // 拿到索引的請求
        IndexRequest request = new IndexRequest("text_index");
        // 設(shè)置id
        request.id("1");
        // 設(shè)置請求的超時時間
        request.timeout("1s");
        // 將數(shù)據(jù)放入request請求
        request.source(JSON.toJSONString(user), XContentType.JSON);
        // 將請求發(fā)送到ES
        IndexResponse index = restHighLevelClient.index(request, RequestOptions.DEFAULT);
        System.out.println("index = " + index.toString());
        System.out.println("index.status() = " + index.status());


    }


    /**
     * 判斷文檔是否存在
     *
     * @throws IOException
     */
    @Test
    void test4() throws IOException {
        // 準(zhǔn)備請求
        GetRequest request = new GetRequest("text_index", "1");
        Boolean exists = restHighLevelClient.exists(request, RequestOptions.DEFAULT);
        System.out.println("exists = " + exists);
    }


    /**
     * 獲取文檔信息
     *
     * @throws IOException
     */
    @Test
    void test5() throws IOException {
        // 準(zhǔn)備請求
        GetRequest request = new GetRequest("text_index", "1");
        // 獲取文檔內(nèi)容
        GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);
        // 獲取文檔中具體存儲的內(nèi)容
        System.out.println(response.getSourceAsString());
        System.out.println(response);
    }


    /**
     * 更新文檔信息
     *
     * @throws IOException
     */
    @Test
    void test15() throws IOException {
        // 準(zhǔn)備數(shù)據(jù)
        User user = new User();
        user.setUsername("穆利帥");
        // 準(zhǔn)備請求
        UpdateRequest request = new UpdateRequest("text_index", "1");
        // 設(shè)置請求超時時間
        request.timeout("2s");
        // 將數(shù)據(jù)放在doc中
        request.doc(JSON.toJSONString(user), XContentType.JSON);
        // 發(fā)送請求
        UpdateResponse update = restHighLevelClient.update(request, RequestOptions.DEFAULT);
        System.out.println("update.status() = " + update.status());
    }


    /**
     * 刪除信息
     *
     * @throws IOException
     */
    @Test
    void test25() throws IOException {
        // 準(zhǔn)備請求
        DeleteRequest request = new DeleteRequest("text_index", "1");
        // 設(shè)置請求超時時間
        request.timeout("2s");
        // 發(fā)送請求
        DeleteResponse delete = restHighLevelClient.delete(request, RequestOptions.DEFAULT);
        System.out.println("update.status() = " + delete.status());
    }

    /**
     * 批量插入
     */
    @Test
    void test11() throws Exception {
        BulkRequest bulkRequest = new BulkRequest();
        bulkRequest.timeout("10s");
        List<User> users = new ArrayList<>();
        users.add(new User("穆利帥0", 24, "beijing"));
        users.add(new User("穆利帥1", 25, "beijing"));
        users.add(new User("穆利帥2", 26, "beijing"));
        users.add(new User("穆利帥3", 27, "beijing"));
        users.add(new User("穆利帥4", 28, "beijing"));
        users.add(new User("穆利帥5", 29, "beijing"));
        for (int i = 0; i < users.size(); i++) {
            // 同樣批量更新和批量刪除也是一樣的
            IndexRequest request = new IndexRequest("text_index");
            request.id(String.valueOf(i))
                    .source(JSON.toJSONString(users.get(i)), XContentType.JSON);
            bulkRequest.add(request);
        }
        BulkResponse bulk = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
        System.out.println("bulk.status() = " + bulk.status());


    }


    /**
     *  查詢
     *
     * @throws Exception
     */
    @Test
    void test111() throws Exception {
      // 準(zhǔn)備請求
        SearchRequest searchRequest = new SearchRequest("text_index");


        // 準(zhǔn)備查詢條件
        SearchSourceBuilder builder = new SearchSourceBuilder();
        //  builder.query(QueryBuilders.termQuery("username","穆利帥1")); // 精確查詢 分詞器不分詞
        builder.query(QueryBuilders.matchQuery("username","穆利帥")); // 分詞查詢 分詞器分詞
        // 起始
        builder.from(0);
        // 每頁數(shù)目
        builder.size(10);
        // 排序
        builder.sort("age", SortOrder.DESC);
        // 設(shè)置查詢條件的過期時間
        builder.timeout(new TimeValue( 60, TimeUnit.SECONDS));



        // 設(shè)置請求條件
        searchRequest.source(builder);
        // 發(fā)出查詢請求
        SearchResponse res = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);

        SearchHit[] hits = res.getHits().getHits();
        for (SearchHit hit : hits) {
            System.out.println("hit.getSourceAsString() = " + hit.getSourceAsString());
        }
    }

}

到了這里,關(guān)于Elasticsearch基礎(chǔ),SpringBoot整合Elasticsearch的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Elasticsearch 整合springboot-Elasticsearch文章二

    Elasticsearch 整合springboot-Elasticsearch文章二

    https://www.elastic.co/cn/ https://docs.spring.io/spring-data/elasticsearch/docs/4.4.10/reference/html/ 我們選用的是elasticsearch 7.17.9版本,對應(yīng)的,我們需要升級springboot版本,對應(yīng)的中間件都需要升級 Springboot: 2.7.10 spring-data-elasticsearch: 4.4.10 spring-boot-starter-data-elasticsearch: 2.7.10 https://github.com/OrderDo

    2024年02月15日
    瀏覽(17)
  • Elasticsearch是什么,如何學(xué)習(xí)Elasticsearch,整合SpringBoot

    Elasticsearch是什么,如何學(xué)習(xí)Elasticsearch,整合SpringBoot

    目錄 一、是什么Elasticsearch 二、Elasticsearch,整合SpringBoot 三、Elasticsearch的優(yōu)勢和應(yīng)用場景 ? Elasticsearch是一個開源的搜索引擎,它采用Java語言編寫,使用Lucene作為核心搜索引擎,并在其基礎(chǔ)上構(gòu)建了分布式的、可擴(kuò)展的、實時的數(shù)據(jù)存儲和分析引擎 。Elasticsearch最初由Shay B

    2024年02月16日
    瀏覽(20)
  • SpringBoot 整合 ElasticSearch

    SpringBoot 整合 ElasticSearch

    ??開始前給大家推薦一款很火的刷題、面試求職網(wǎng)站?? https://www.nowcoder.com/link/pc_csdncpt_xiaoying_java 索引Index 一組相似文檔的集合 一個索引就是一個擁有幾分相似特征的文檔的集合。比如說,你可以有一個商品數(shù)據(jù)的索引,一個訂單數(shù)據(jù)的索引,還有一個用戶數(shù)據(jù)的索引。一

    2023年04月08日
    瀏覽(18)
  • 三.SpringBoot整合Elasticsearch

    三.SpringBoot整合Elasticsearch

    我們整合es直接給es發(fā)請求就可以了,但是現(xiàn)在有很多方式去調(diào)用es的接口,那都有那些呢? 訪問es端口 訪問方式 使用工具 缺點 9300 TCP transport-api.jar 不適配es版本,es 8.0之后棄用。 9200 HTTP JestClient 非官方,對應(yīng)es版本更新慢。 9200 HTTP RestTemplate 模擬發(fā)送http請求,但是很多請求

    2024年02月13日
    瀏覽(21)
  • ElasticSearch(九)【SpringBoot整合】

    ElasticSearch(九)【SpringBoot整合】

    上一篇文章 《ElasticSearch - 過濾查詢》 9.1 基本環(huán)境配置 創(chuàng)建一個springboot工程 springboot-elasticsearch 在 pom.xml 導(dǎo)入依賴 【 注意 】使用的springboot需要根當(dāng)前ES版本兼容 配置 application.yml 文件 配置客戶端 創(chuàng)建config包,添加配置類 RestClientConfiguration.class 配置完之后,該配置類不僅

    2024年02月14日
    瀏覽(54)
  • ElasticSearch系列 - SpringBoot整合ES:ElasticSearch分析器

    1. ElasticSearch match 文本搜索的過程? Elasticsearch 的 match 查詢是一種基于文本匹配的查詢方式,它的搜索過程如下: ① 將查詢字符串分詞:Elasticsearch 會將查詢字符串分成一個個詞項(term),并去除停用詞(如“的”、“是”等常用詞匯)和標(biāo)點符號等無意義的字符。 ② 構(gòu)建

    2023年04月18日
    瀏覽(25)
  • Springboot整合Elasticsearch(Es)

    Springboot整合Elasticsearch(Es)

    首先 在測試類中引入RestHighLevelClient對象 其次 準(zhǔn)備一個User對象 3.1.1 創(chuàng)建索引 ?運行結(jié)果:創(chuàng)建成功返回true 3.1.2 刪除索引 運行結(jié)果:刪除成功返回true ?3.1.3 判斷索引是否存在 運行結(jié)果:存在返回true,不存在返回false. 3.2.1 添加文檔 運行結(jié)果:添加成功返回 CREATED 3.2.2 查詢文檔--

    2023年04月22日
    瀏覽(24)
  • springboot整合elasticsearch使用案例

    springboot整合elasticsearch使用案例

    完成搜索和分頁 添加品牌、城市、星級、價格等過濾功能 搜索我附近的酒店 ? ?讓指定的酒店在搜索結(jié)果中排名置頂 添加isAD字段

    2024年02月09日
    瀏覽(17)
  • springboot整合elasticsearch8

    1.引入maven依賴 2.application.yml添加配置 3.編寫config文件 啟動demo項目,通過控制臺日志查看是否能夠正常連接es。 4.在DemoApplicationTests編寫簡單測試操作es。

    2024年02月12日
    瀏覽(21)
  • SpringBoot整合ElasticSearch版本問題

    最近在整個這兩個框架,發(fā)現(xiàn)老是版本對不上,不是缺少類,就是啟動不了,美好的一下午就這樣浪費了,多說一句廢話,es的版本更新速度也太快了,如果spring boot已經(jīng)固定的,注意一下es的版本。 下面的這個鏈接是spring官方提供的兼容版本 springboot與elasticsearch兼容版本對應(yīng)

    2024年02月15日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包