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

在數(shù)據(jù)量很大的時候使用的lunce

這篇具有很好參考價值的文章主要介紹了在數(shù)據(jù)量很大的時候使用的lunce。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

?

?Lucene功能

? ? ? ? 1.可擴(kuò)展的高性能索引

????????2.強(qiáng)大、準(zhǔn)確、高效的搜索算法

????????3.跨平臺解決方案?

?適用場景

? ? 在應(yīng)用中為數(shù)據(jù)庫中的數(shù)據(jù)提供全文檢索實現(xiàn)。
?? ?開發(fā)獨立的搜索引擎服務(wù)、系統(tǒng)。
?? ?對于數(shù)據(jù)量大、數(shù)據(jù)結(jié)構(gòu)不固定的數(shù)據(jù)可采用全文檢索方式搜索。
?? ?任意? ? ? ? ? ? 結(jié)構(gòu)化搜索
?? ??????????????????? ?全文搜索
?? ??????????????????? ?分面
?? ??????????????????? ?跨高維向量的最近鄰搜索
?? ??????????????????? ?拼寫糾正或查詢建議的應(yīng)用程序

架構(gòu)

????????結(jié)構(gòu)化數(shù)據(jù)搜索與非結(jié)構(gòu)化數(shù)據(jù)搜索對比分析

在數(shù)據(jù)量很大的時候使用的lunce,lucene,ik

?

?

?

? ? ? ? 1.需要的pom文件

?

<dependencies>
        <!-- Web依賴 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- MySQL驅(qū)動 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- Mybatis-Plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.2</version>
        </dependency>
        <!-- 引入Lucene核心包及分詞器包 -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>4.10.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-common</artifactId>
            <version>4.10.3</version>
        </dependency>
        <!-- 熱部署 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <!-- Lombok工具 -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- IK中文分詞器 -->
        <dependency>
            <groupId>com.janeluo</groupId>
            <artifactId>ikanalyzer</artifactId>
            <version>2012_u6</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

? ? ? ? 2.核心配置文件

#訪問的端口
server.port=9000
spring.application.name=lunce

spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/es_db?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=0216


# 開啟駝峰命名匹配映射
mybatis-plus.configuration.map-underscore-to-camel-case=true

? ? ? ? 3.job_info表對應(yīng)的實體類

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("job_info")
public class JobInfo {
    @TableId(type = IdType.AUTO)
    private Long id; // id屬性建議使用包裝類定義
    private String companyName;
    private String companyAddr;
    private String companyInfo;
    private String jobName;
    private String jobAddr;
    private String jobInfo;
    private int salaryMin;
    private int salaryMax;
    private String url;
    private String time;
}

? ? ? ? ? 4.mapper層

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lucene.demo.dommain.JobInfo;

public interface JobInfoMapper extends BaseMapper<JobInfo> {

}

? ? ? ? 5.service層

? ? ? ? 接口

import com.lucene.demo.dommain.JobInfo;

import java.util.List;

public interface JobInfoService {
    JobInfo selectById(Long id);
    List<JobInfo> selectAll();
}

????????實現(xiàn)類

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lucene.demo.dommain.JobInfo;
import com.lucene.demo.mapper.JobInfoMapper;
import com.lucene.demo.service.JobInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobInfoServiceImpl implements JobInfoService {
    @Autowired
    private JobInfoMapper jobInfoMapper;

    @Override
    public JobInfo selectById(Long id) {
        return jobInfoMapper.selectById(id);
    }

    @Override
    public List<JobInfo> selectAll() {
        List<JobInfo> ji = jobInfoMapper.selectList(new QueryWrapper<>());
        return ji;
    }
}

? ? ? ? 到這里我們的準(zhǔn)備工作就算完成了,然后開始給大文件的數(shù)據(jù)創(chuàng)建索引

@Test
    public void createIndex() throws IOException {//數(shù)據(jù)中查詢數(shù)據(jù),給其建立索引
        //1.指定索引文件存儲位置
        Directory directory = FSDirectory.open(new File("D:\\1javaweb\\index"));
        //2.配置分詞器,版本信息
//        Analyzer analyzer =new StandardAnalyzer();//Lucene提供的標(biāo)準(zhǔn)分詞器
        Analyzer analyzer =new IKAnalyzer();//IK分詞器
        //指定版本      Version.LATEST最新版本
        IndexWriterConfig config =new IndexWriterConfig(Version.LATEST,analyzer);
        //3.創(chuàng)建一個用來寫入索引的數(shù)據(jù)的對象IndexWriter
        //  1). 索引寫入目標(biāo)文件的位置          2).按照哪一個標(biāo)準(zhǔn)分詞器寫出數(shù)據(jù)
        IndexWriter writer = new IndexWriter(directory,config);
        // 刪除指定目錄下的所有索引數(shù)據(jù)
        writer.deleteAll();
        //4.從Mysql數(shù)據(jù)庫中查詢的數(shù)據(jù)交給Lucene寫入到index目錄下并創(chuàng)建索引
       List<JobInfo> jobInfos = jobInfoService.selectAll();
       //5.循環(huán)遍歷集合
        for (JobInfo jobInfo:jobInfos) {
            //創(chuàng)建文檔對象 :Document是用來存儲數(shù)據(jù)庫中的一條記錄
            Document d =new Document();
            //document中添加field(數(shù)據(jù)庫字段信息):數(shù)據(jù)類型,取值      YES永久存儲      NO只用一次
            d.add(new LongField("id",jobInfo.getId(), Field.Store.YES));

            d.add(new TextField("companyName",jobInfo.getCompanyName(), Field.Store.YES));
            d.add(new TextField("companyAddr",jobInfo.getCompanyAddr(), Field.Store.YES));

            d.add(new IntField("salaryMax",jobInfo.getSalaryMax(), Field.Store.YES));
            d.add(new IntField("salaryMin",jobInfo.getSalaryMin(), Field.Store.YES));

            d.add(new StringField("url",jobInfo.getUrl(), Field.Store.YES));
            d.add(new StringField("time",jobInfo.getTime(), Field.Store.YES));


            //將當(dāng)前的document文檔寫入到
            writer.addDocument(d);
        }
        //關(guān)閉資源
        writer.close();
   }

? ? ? ? 通過索引進(jìn)行搜索,更加快速簡便

//查詢索引
    @Test
    public void queryIndex() throws IOException {
        //1.指定索引文件存儲位置
        Directory directory = FSDirectory.open(new File("D:\\1javaweb\\index"));
        //2.創(chuàng)建一個讀取索引.文件數(shù)據(jù)的對象
        IndexReader ir = DirectoryReader.open(directory);
        //3.創(chuàng)建一個用來搜索索引中數(shù)據(jù)的對象
        IndexSearcher is =new IndexSearcher(ir);
        // 使?term查詢:指定查詢的域名和關(guān)鍵字
         Query query = new TermQuery(new Term("companyName","京"));
        TopDocs search = is.search(query, 100);
        System.out.println("查詢到的總數(shù):"+search.totalHits);
        System.out.println("maxScore:"+search.getMaxScore());


        ScoreDoc[] scoreDocs = search.scoreDocs;
         //遍歷文檔的數(shù)據(jù)
        for (ScoreDoc scoreDoc : scoreDocs) {
            //獲取id
           int docId =  scoreDoc.doc;
            //根據(jù)id獲取文檔的對象
            Document doc = is.doc(docId);

            System.out.println("id:"+doc.get("id"));
            System.out.println("companyName:"+doc.get("companyName"));
            System.out.println("companyAddr:"+doc.get("companyAddr"));
            System.out.println("slaryMax:"+doc.get("slaryMax"));
            System.out.println("slaryMin:"+doc.get("slaryMin"));
            System.out.println("url:"+doc.get("url"));
            System.out.println("================");
        }


    }

在數(shù)據(jù)量很大的時候使用的lunce,lucene,ik

?

?對索引的解析?

????????Index索引:在Lucene中一個索引是存放在一個文件夾中的
????????Segment段:按層次保存了索引到詞的包含關(guān)系:索引(Index) => 段(segment) => 文檔(Document) => 域(Field) => 詞(Term)
?? ??? ?????????????????即此索引包含了哪些段,每個段包含了哪些文檔,每個文檔包含了哪些域,每個域包含了哪些詞。
?? ??? ?????????????????一個索引可以包含多個段,段與段之間是獨立的,添加新文檔可以生成新的段,不同的段可以合并。
?? ??????????? ?????????如上圖中,具有相同前綴前件的屬同同個段,圖中共三個段?
? ? ? ? ? ? ? ? ? ? ???segments_8和segments.gen是段的元數(shù)據(jù)文件,也即它們保存了段的屬性信息
????????Field的特性:? ? 是否分詞(tokenized)???????? 拆分輸入的關(guān)鍵詞
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?是否索引(indexed)? ? ? ? ???用戶查詢條件的詞作為索引
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?是否存儲(stored)? ? ? ? ? ? ?將Field值保存在Document中
?????????Field類????????? ?LongField:數(shù)值型代表???????? ?TextField:文本類型???????? ?IntField:數(shù)字類型?????????StringField:字符串文章來源地址http://www.zghlxwxcb.cn/news/detail-524554.html

到了這里,關(guān)于在數(shù)據(jù)量很大的時候使用的lunce的文章就介紹完了。如果您還想了解更多內(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ù)器費(fèi)用

相關(guān)文章

  • es 在數(shù)據(jù)量很大的情況下(數(shù)十億級別)如何提高查詢效率?_es能存多少數(shù)據(jù)

    es 在數(shù)據(jù)量很大的情況下(數(shù)十億級別)如何提高查詢效率?_es能存多少數(shù)據(jù)

    先自我介紹一下,小編浙江大學(xué)畢業(yè),去過華為、字節(jié)跳動等大廠,目前阿里P7 深知大多數(shù)程序員,想要提升技能,往往是自己摸索成長,但自己不成體系的自學(xué)效果低效又漫長,而且極易碰到天花板技術(shù)停滯不前! 因此收集整理了一份《2024年最新軟件測試全套學(xué)習(xí)資料》

    2024年04月26日
    瀏覽(36)
  • 使用docker數(shù)據(jù)卷解決掛載目錄的時候文件消失不見的問題

    之前使用掛載目錄掛載docker內(nèi)的配置文件的時候,發(fā)現(xiàn)本地的目錄為空,想到用容器卷來解決,解決完以后一些操作會方便很多 卷 (Docker Volume) 是受控存儲,是由 Docker 引擎進(jìn)行管理維護(hù)的。因此使用卷,你可以不必處理 uid、SELinux 等各種權(quán)限問題,Docker 引擎在建立卷時會自

    2024年02月05日
    瀏覽(23)
  • LUNA vs. LUNC: 哪個是更糟糕的投資

    LUNA vs. LUNC: 哪個是更糟糕的投資

    Sept. 2022, Mike Antolin Data Source: Terra Luna Classic (LUNC) Luna 于2018年推出,最初被開發(fā)為 Terra 的第一個本土代幣。他們把它稱為 LUNA。 它的目的是作為一種補(bǔ)充代幣,吸收加密貨幣基于智能合約的穩(wěn)定幣 terraUSD(UST)的任何價格波動。UST 將通過一種算法創(chuàng)造和銷毀UST代幣來維持其與

    2024年02月01日
    瀏覽(16)
  • 互聯(lián)網(wǎng)大廠技術(shù)-elasticsearch(es)- 在數(shù)據(jù)量很大的情況下(數(shù)十億級別)提高查詢效率

    互聯(lián)網(wǎng)大廠技術(shù)-elasticsearch(es)- 在數(shù)據(jù)量很大的情況下(數(shù)十億級別)提高查詢效率

    互聯(lián)網(wǎng)大廠技術(shù)-elasticsearch(es)- 在數(shù)據(jù)量很大的情況下(數(shù)十億級別)提高查詢效率 目錄 一、問題分析 二、問題剖析 三、性能優(yōu)化的殺手锏(filesystem cache) 四、數(shù)據(jù)預(yù)熱 五、冷熱分離 六、document 模型設(shè)計 七、分頁性能優(yōu)化 八、解決方案 這個問題是肯定要問的,說白了,就

    2024年02月04日
    瀏覽(26)
  • Java輕量級全文檢索引擎Lucene使用及優(yōu)化

    Lucene是一個開源的全文檢索引擎工具包由Doug Cutting編寫。它被設(shè)計用于實現(xiàn)全文搜索功能,即讀入一堆文本文件并將其轉(zhuǎn)換為易于搜索的數(shù)據(jù)結(jié)構(gòu)。Lucene提供了一組簡單而強(qiáng)大的API,使得索引和搜索過程變得非常方便。 Lucene廣泛應(yīng)用于從1200萬站點中進(jìn)行互聯(lián)網(wǎng)搜索等搜索引

    2024年02月16日
    瀏覽(19)
  • ElasticSearch學(xué)習(xí)篇10_Lucene數(shù)據(jù)存儲之BKD動態(tài)磁盤樹

    ElasticSearch學(xué)習(xí)篇10_Lucene數(shù)據(jù)存儲之BKD動態(tài)磁盤樹

    基礎(chǔ)的數(shù)據(jù)結(jié)構(gòu)如二叉樹衍生的的平衡二叉搜索樹通過左旋右旋調(diào)整樹的平衡維護(hù)數(shù)據(jù),靠著二分算法能滿足一維度數(shù)據(jù)的logN時間復(fù)雜度的近似搜索。對于大規(guī)模多維度數(shù)據(jù)近似搜索,Lucene采用一種BKD結(jié)構(gòu),該結(jié)構(gòu)能很好的空間利用率和性能。 本片博客主要學(xué)習(xí)常見的多維

    2024年03月15日
    瀏覽(23)
  • flutter3使用dio庫發(fā)送FormData數(shù)據(jù)格式時候的坑,和get庫沖突解決辦法

    flutter3使用dio庫發(fā)送FormData數(shù)據(jù)格式時候的坑,和get庫沖突解決辦法

    問題1:當(dāng)你使用 FormData.from(Flutter3直接不能用) 的時候,可能會提示沒有這個方法,或者使用 FormData.fromMap(flutter3的dio支持) 的時候也提示沒有,這時候可能就是和get庫里面的Formdata沖突了 問題1:The method \\\'fromMap\\\' isn\\\'t defined for the type \\\'FormData\\\'. (Documentation) ?Try correcting the name to

    2024年01月19日
    瀏覽(38)
  • Elasticsearch 8.9 refresh刷Es緩沖區(qū)的數(shù)據(jù)到Lucene,更新segemnt,使數(shù)據(jù)可見

    Elasticsearch 8.9 refresh刷Es緩沖區(qū)的數(shù)據(jù)到Lucene,更新segemnt,使數(shù)據(jù)可見

    下面的圖來自ElasticSearch——刷盤原理流程,這篇文章主要講的是refresh命令把ES寫入索引緩沖區(qū)的數(shù)據(jù)刷進(jìn)Lucene,使數(shù)據(jù)可供查詢,搜索,否則,在索引緩沖區(qū)是不可見的,不涉及到在 translog.log 和 Lucene 的數(shù)據(jù)結(jié)構(gòu)。 通過這個流程知道ES如何把索引緩沖區(qū)的數(shù)據(jù)刷進(jìn)Lucene的,

    2024年02月04日
    瀏覽(20)
  • 加速大規(guī)模數(shù)據(jù)處理和多維分析:基于Lucene和Hadoop的開源項目

    大數(shù)據(jù)時代帶來了處理和分析海量數(shù)據(jù)的挑戰(zhàn),我很高興向大家介紹我的個人開源項目:Lucene-Hadoop。這個項目基于Lucene和Hadoop,旨在提供高效的數(shù)據(jù)存儲和查詢引擎,加速大規(guī)模數(shù)據(jù)處理和多維分析。 項目介紹 https://github.com/arlixu/lucene-hadoop Lucene-Hadoop利用Lucene和Hadoop的強(qiáng)大

    2024年02月08日
    瀏覽(25)
  • ElasticSearch學(xué)習(xí)篇8_Lucene之?dāng)?shù)據(jù)存儲(Stored Field、DocValue、BKD Tree)

    ElasticSearch學(xué)習(xí)篇8_Lucene之?dāng)?shù)據(jù)存儲(Stored Field、DocValue、BKD Tree)

    Lucene全文檢索主要分為索引、搜索兩個過程,對于索引過程就是將文檔磁盤存儲然后按照指定格式構(gòu)建索引文件,其中涉及數(shù)據(jù)存儲一些壓縮、數(shù)據(jù)結(jié)構(gòu)設(shè)計還是很巧妙的,下面主要記錄學(xué)習(xí)過程中的StoredField、DocValue以及磁盤BKD Tree的一些相關(guān)知識。 參考: https://juejin.cn/p

    2024年02月03日
    瀏覽(65)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包