Spring Boot+Elasticsearch实现简单全文搜索

利用springboot+elasticSearch,实现数据高效搜索,实战开发 每天早上七点三十,准时推送干货一、介绍在2018年10月5日,一个做数据搜索服务的软件初创公司 Elastic,在纳斯达克上市。而我们所熟悉的 ElasticSearch,正是 Elas... 阅读详情

elasticsearch

ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于[云计算]中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
spring boot操作elasticsearch需要通过spring data elasticsearch来实现
添加依赖:
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
实现效果:

微信截图_20180521120057.png

实体类:

package com.example.demo.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;



/**
 * Created by linziyu on 2018/5/19.
 * 实体类
 *
 *
 */
//定义索引名字及类型
@Document(indexName = "poem",type = "poem",shards = 1, replicas = 0)
public class Poem {
   
   

    @Id
    private long id;
    private String title;
    private String content;

    public Poem(long id, String title, String content) {
        this.id = id;
        this.title = title;
        this.content = content;
    }

    public Poem(String title, String content) {
        this.title = title;
        this.content = content;
    }

    public Poem() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        
使用Elasticsearch与Spring Boot集成实现全文搜索 文章目录启动Elasticsearch修改application.properties创建文档类创建资源库创建测试用例 今天在实验室摸索了一天Elasticsearch与Spring Boot集成,终于初见成效,很开心,mark一下。 启动Elasticsearch 首先,确保已经正确启动了Elasticsearch服务器,windows系统运行Elasticsearch解压文件下的bin/ela... 阅读详情

相关推荐

Spring Boot Data Elasticsearch多重搜索

msearch是Elasticsearch提供的API,用于执行多个搜索请求,而multiSearchRequest是Spring Data Elasticsearch中用于构建和执行msearch请求的具体实现。当然也可以在一个索引中执行多次搜索,但是我现在想要的是在多个索引中分别构建Query进行查询,然而在spring-boot-starter-data-elasticsearch 2.3.12.RELEASE版本中没有对应的API。由于是接口,可以被不同的实现类扩展。

qq_38207331的博客 1414

Spring Boot中如何集成ElasticSearch进行全文搜索

通过本文,我们学习了如何在Spring Boot应用中集成ElasticSearch进行全文搜索。从创建Spring Boot项目开始,到配置ElasticSearch连接,再到编写实体类、Repository、Service和Controller,我们逐步完成了集成的过程。

聚娃科技开发者博客 955

SpringBoot3 + Elasticsearch 实战:30分钟搞定全文搜索功能

Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎。它能很方便的使大量数据具有搜索、分析和探索的能力。充分利用Elasticsearch的水平伸缩性,能使数据在生产环境变得更有价值。Elasticsearch 的实现原理主要分为以下几个步骤,首先用户将数据提交到Elasticsearch 数据库中,再通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据,当用户搜索数据时候,再根据权重将结果排名,打分,再将返回结果呈现给用户。

spb229443329的专栏 1701

SpringBoot整合ElasticSearch-全文搜索

1、何为全文搜索? 全文搜索本质:非结构化数据转成结构化数据,提取非结构化数据 概念: 原理: 实现技术: 其中lucene是搜索引擎,ElasticSearch和solr是基于Lucene 2、添加依赖 // 添加spring data Elasticsearch依赖 compile('org.springframework.boot:spring-bo...

wendy专栏 5661

Spring Boot整合Elasticsearch,最新最全教程

要想快速入门新技术,英文文档的阅读能力必不可少。本篇文章主要参考《Spring Data Elasticsearch》Spring Boot整合Elasticsearch的官方文档。 Elasticsearch官网参考文档:https://www.elastic.co/guide/index.html Elasticsearch官方下载地址:https://www.elastic.co/cn/downloads/elasticsearch Elasticsearch目前最近版本为:7.10.1 最近系统.

Cloud-Future的博客 10万+

springboot整合全文搜索引擎Elasticsearch | Spring Boot 28

???? Java学习路线配套文章:Java学习路线总结,搬砖工逆袭Java架构师(全网最强) ???? 基础推荐:Java基础教程系列 ???? 实战推荐:Spring Boot基础教程 ???? 简介:Java领域优质创作者????、优快云哪吒公众号作者✌ 、Java架构师奋斗者???? ???? 扫描主页左侧二维码,加入群聊,一起学习、一起进步 ???? 欢迎点赞 ???? 收藏 ⭐留言 ???? 目录一、Elasticsearch简介二、下载与安装1、Elasticsearch官网下载地址2、下

学Java,找哪吒 1万+

Spring Boot如何整合Elasticsearch进行全文搜索?一文教你搞定!

🏆本文收录于《滚雪球学Spring Boot》,专门攻坚指数提升,2025 年国内最系统+最强(更新中)。    本专栏致力打造最硬核 Spring Boot 从零基础到进阶系列学习内容,🚀均为全网独家首发,打造精品专栏,专栏持续更新中…欢迎大家订阅持续学习。 如果想快速定位学习,可以看这篇【SpringBoot教程导航帖】,你想学习的都被收集在内,快速投入学习!!两不误。

**My Coding Family** 1241

Spring Boot进阶(19):探索ElasticSearch:如何利用Spring Boot轻松实现高效数据搜索与分析

SpringBoot如何集成ElasticSearch,你不会我教你呀~~

**My Coding Family** 4881

Spring Boot 与 Elasticsearch 搜索引擎整合

数据同步:如何将关系型数据库(如MySQL)中的数据实时同步到ES?查询性能:如何优化复杂查询(如多条件过滤、聚合)的响应时间?分布式一致性:ES集群分片/副本机制下,如何保证数据的可靠性?开发效率:如何避免重复编写ES客户端代码,实现"面向对象"的搜索开发?使用@Document和@Field@Data@Document(indexName = "product", shards = 3, replicas = 2) // 3分片,2副本@Id // 对应ES文档的_id字段。

架构师的AI之路,分享AI应用开发架构的学习与实践。 1171

Elasticsearch实现全文搜索的步骤和实现原理

在分布式搜索中,Elasticsearch 使用一种叫做倒排索引分布式的技术来加速搜索。当搜索请求到达时,各个分片将自己的搜索结果返回给协调节点(coordinator),协调节点负责合并、排序和返回最终的搜索结果。ElasticSearch(简称为ES)是一个基于开源的分布式搜索和分析引擎,它提供了强大的全文搜索、结构化查询、实时数据分析和可视化等功能。倒排索引是一种将文档中的词汇出现映射到文档的数据结构,它提供了快速查找某个词汇在哪些文档中出现的能力。这样可以保证搜索时能够准确匹配到文档中的词汇。

热爱技术,享受生活 1万+

Spring Boot 中使用 Elasticsearch 实现商品搜索功能

作者:禅与计算机程序设计艺术 1.简介 Elasticsearch 是开源分布式搜索引擎,它提供了一个分布式、RESTful 搜索接口。基于 Elasticsearch 的搜索方案能够轻松应对复杂的检索场景并提供高扩展性。在 Web 应用中,Elasticsearch 可以作为后台服务支持用户的检索需求

AI天才研究院 2825

FPGA高速接口Aurora8B/10B协议实战:从IP核配置到数据流优化

本文详细介绍了FPGA高速接口Aurora8B/10B协议的实战应用,从IP核配置到数据流优化的全流程。通过Aurora8B/10B协议,开发者可以在FPGA间实现高效的数据传输,适用于高速接口设计。文章涵盖了协议基础、IP核配置、AXI4-Stream接口实战技巧以及性能优化策略,帮助读者快速掌握这一关键技术。

weixin_29280657的博客 268

【01】VisionMaster入门到精通——VisionMaster V4.0.0 试用版安装教程(安装试用补丁与试用授权)

本文详细介绍了海康VisionMaster 4.0.0试用版的安装步骤:首先从官网下载基础安装包、软加密试用版和示例程序(可选);安装时需按顺序完成主程序安装(选择软加密)、试用补丁安装和30天试用授权安装;最后提供了两种启动方式。文章还列出了试用版的7项功能限制,包括最多支持2个流程、2个全局相机等,并特别提醒试用版不维护、不提供补丁,建议用户转为正式版本。安装过程中若出现蓝屏需重启覆盖安装,授权失败时可参考指定解决方案。

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 8861

把 ABAP 开发对象装进 XML 行李箱:SAPlink 安装、插件、升级与协作迁移全指南

SAPlink是一款用于在SAP NetWeaver系统间导入导出ABAP对象的工具,特别适合临时协作、系统孤岛等场景。它通过XML文件(Slinkee和Nugget两种格式)传输开发对象,支持插件扩展多种对象类型。安装时需注意版本兼容性、权限和激活流程,使用时要区分覆盖选项的风险。相比正式运输系统,SAPlink更适用于快速共享、原型交付等非生产场景,但需配合命名规范和协作策略确保可维护性。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 151

MyBatis-Plus 实战:敏感字段自动加解密支持模糊查询

本文基于MyBatis-Plus框架提出了一种全链路敏感字段加密方案。通过自定义TypeHandler实现数据入库自动加密和查询自动解密,结合重写LambdaQueryWrapper处理查询条件加密,并适配多种查询方式。方案核心包括:1)AESUtil工具类提供加解密基础能力;2)EncryptTypeHandler实现字段类型转换;3)实体类通过注解配置加密字段。该方案在保证数据安全的同时,对业务代码侵入性小,支持姓名、手机号等敏感信息的全流程加密处理,满足系统开发的安全需求。

蔡定努 595

Python爬虫实战:股票历史数据抓取与量化回测全流程详解

我们以**东方财富网(eastmoney.com)和雪球网(xueqiu.com)**为主要目标,演示如何爬取A股历史行情。最常用的HTTP请求库,简单易用,适合静态页面数据请求。本文详细介绍了从股票历史数据抓取到简单回测的完整流程,代码示例基于最新技术,结构清晰,适合初学者和进阶者学习量化投资实战。希望对你入门Python爬虫和量化交易有所帮助!

2201_76125261的博客 1778

[VCS]门级仿真及SDF反标

摘要:门级仿真在STA工具普及后仍是验证的重要环节,主要用于检查SDC完备性、异步电路时序、网表完整性及为功耗分析提供波形。门级仿真分为不带时序反标的前仿和带SDF反标的后仿,后仿需加载SDF文件提供精确延时信息。VCS提供多种仿真选项控制时序检查行为,SDF反标可通过命令或系统函数实现。后仿需特别注意关闭notimingcheck选项以确保时序检查有效性,并建议检查SDF反标报告和波形验证延时一致性。

元直的博客 9787

高频网络协议与编程IO相关面试基本问题和知识点整理

网络IO相关基本高频面试基本问题和知识点整合

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 173万+

PCL 基于强度的双边滤波【2026最新版】

基于强度信息的双边滤波代码实现、滤波前后点云未出现变化的原因以及获取带有强度pcd点云的方法。本文由优快云点云侠原创,博客长期更新,本文最近一次更新时间为:2026年5月24日。

点云侠的博客 29万+

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: Spring Boot+Spring Security+MySql实现用户权限管理(3)
下一篇: SpringBoot-Mybatis-SpringSecurity-LayUI的简单用户权限管理
Coder_py
博客等级 码龄10年 106粉丝 258原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值