当前位置: 首页 > news >正文

这个是以前我自己做的一个网站中国舆情网

这个是以前我自己做的一个网站,中国舆情网,长沙县疫情最新消息,wordpress动态计时1、ES搜索引擎,高性能的分布式搜索引擎,底层基于Lucene 主要用于应用程序中的搜索系统 日志收集 2、基础概念 3、ES处理流程 5、下载中文分词器 Releases infinilabs/analysis-ik GitHub 6、分词模式 最细粒度拆分、智能分词 7、Elaticsearch配置流程 (1)把文件拖进…

1、ES搜索引擎,高性能的分布式搜索引擎,底层基于Lucene

主要用于应用程序中的搜索系统

日志收集

2、基础概念

3、ES处理流程

5、下载中文分词器

Releases · infinilabs/analysis-ik · GitHub

6、分词模式

最细粒度拆分、智能分词

7、Elaticsearch配置流程

(1)把文件拖进去,然后执行

(2)访问Elastic

8、分词器

 9、客户端集成的三种方式(第二种用的多)

​​​​​​​

10、es返回的是对象本身,更新本质是保存的操作

11、statement模式默认值丢失、row模式不会、智能模式

12、Query 复杂查询(用第三个)

13、ES语法

查询所有行跟列

MatchAllQueryBuilder

过滤行   

限定符

逻辑

 must()   and   should()  or

模糊查询

WildcardQueryBuilder

精确查询

MatchPhraseQueryBuilder

范围判断 between and

RangeQueryBuilder,gt、lt、gte

包含 in

分组统计

 排序

权重

综合排序

    @Testpublic void search(){//查询所有MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();//分页NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(matchAllQueryBuilder);nativeSearchQuery.setPageable(PageRequest.of(0,100));SearchHits<EsProduct> searchHits = elasticsearchRestTemplate.search(nativeSearchQuery, EsProduct.class);List<EsProduct> esProducts = searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());log.info(esProducts.toString());}

14、模糊查询

? 单个单词* 匹配多个
​​​​​​​匹配的内容如果是多个中文
多个中文单词匹配在查询字段后面使用.keyword

15、ES使用流程(先部署上去7)

(1)导包

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

(2)配置

server:port: 8081
spring:elasticsearch:uris: "http://129.204.151.181:9200"username: ""password: ""connection-timeout: 2s

(3)写实体类

package com.smart.community.es.entity;import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;import java.math.BigDecimal;
import java.util.List;/*** @author liuhuitang*/
@Data
@Document(indexName = "product_index")
public class EsProduct {@Idprivate Long productId;@Field(value = "product_name",analyzer = "ik_smart",searchAnalyzer = "ik_smart")private String productName;@Fieldprivate BigDecimal productPrice;private List<String> imageUrls;@Field(value = "shop_name",analyzer = "ik_smart",searchAnalyzer = "ik_smart")private String shopName;private Long shopId;}

(4)ProductVo(没用上)

package com.smart.community.es.common.vo;import lombok.Data;import java.math.BigDecimal;
import java.util.List;/*** @author liuhuitang*/
@Data
public class ProductVo {private String productName;private BigDecimal productPrice;private List<String> imageUrls;}

(5)EsProductDao层

package com.smart.community.es.dao;import com.smart.community.es.entity.EsProduct;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.stereotype.Repository;/*** 创建数据库* @author liuhuitang*/public interface EsProductDao {@Query("/product_product/product/1")EsProduct save(EsProduct esProduct);EsProduct update(EsProduct esProduct);}
package com.smart.community.es.dao.impl;import com.smart.community.es.dao.EsProductDao;
import com.smart.community.es.entity.EsProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Repository;/*** @author liuhuitang*/
@Repository
public class EsProductDaoImpl implements EsProductDao {@Autowiredprivate ElasticsearchRestTemplate restTemplate;@Overridepublic EsProduct save(EsProduct esProduct) {return restTemplate.save(esProduct);}@Overridepublic EsProduct update(EsProduct esProduct) {return null;}
}

(6)测试

package com.smart.community.es.dao.impl;import cn.hutool.core.util.RandomUtil;
import com.smart.community.es.dao.EsProductDao;
import com.smart.community.es.entity.EsProduct;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;import static org.junit.jupiter.api.Assertions.*;@SpringBootTest
class EsProductDaoImplTest {@Autowiredprivate EsProductDao productDao;@Autowiredprivate ElasticsearchRestTemplate restTemplate;@Testvoid save() {EsProduct esProduct = new EsProduct();esProduct.setProductId(1L);esProduct.setProductName("测试商品");esProduct.setProductPrice(new BigDecimal("1.00"));esProduct.setShopId(100L);esProduct.setShopName("测试店铺");productDao.save(esProduct);}/*** 生成100条测试数据并保存*/@Testvoid batchSave(){List<EsProduct> products = Stream.generate(RandomUtil::randomInt).limit(100).map(id -> {EsProduct esProduct = new EsProduct();esProduct.setProductId(Long.valueOf(id));esProduct.setProductName("测试商品" + id);esProduct.setShopName("测试店铺" + id);BigDecimal randomPrice = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("100000000.00"));esProduct.setProductPrice(randomPrice.setScale(2, RoundingMode.HALF_UP));esProduct.setShopId(1L);return esProduct;}).collect(Collectors.toList());restTemplate.save(products);}}
package com.qf.cloud.es.dao.impl;import com.qf.cloud.es.entity.EsProduct;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.index.query.*;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;@SpringBootTest
@Slf4j
public class ElasticsearchRestTemplateTest {@ResourceElasticsearchRestTemplate elasticsearchRestTemplate;/*** 查询  search* NativeSearchQuery  复杂的查询* 查询所有行跟列* 过滤行   限定符     逻辑   模糊查询   精确查询  范围判断 between   and    包含 in* 分组统计* 排序    权重   综合排序* match_all* <p>* 过滤列*/@Testpublic void search() {MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(matchAllQueryBuilder);nativeSearchQuery.setPageable(PageRequest.of(1, 100));SearchHits<EsProduct> searchHits = elasticsearchRestTemplate.search(nativeSearchQuery, EsProduct.class);List<EsProduct> esProducts = searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());log.info(esProducts.toString());}/*** 返回查询*/@Testpublic void testRangeQueryBuilder() {/***  gt >   <  lt  >= gte <= lte* between  and*/RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("productId");rangeQueryBuilder.gt(10);NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(rangeQueryBuilder);SearchHits<EsProduct> searchHits = elasticsearchRestTemplate.search(nativeSearchQuery, EsProduct.class);List<EsProduct> esProducts = searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());log.info(esProducts.toString());}/***  通配符*  ? 单个单词*  * 匹配多个**  匹配的内容的多个中文*  多个中文单词匹配在查询字段后面使用.keyword*//*** 模糊查询*/@Testpublic void testWildcardQuery() {WildcardQueryBuilder wildcardQuery = QueryBuilders.wildcardQuery("product_name.keyword", "*测试*");NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(wildcardQuery);SearchHits<EsProduct> searchHits = elasticsearchRestTemplate.search(nativeSearchQuery, EsProduct.class);List<EsProduct> esProducts = searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());log.info(esProducts.toString());}/*** =*/@Testpublic void testMatchPhraseQueryBuilder() {/***  通配符*  ? 单个单词*  * 匹配多个**  匹配的内容的多个中文*  多个中文单词匹配在查询字段后面使用.keyword*/MatchPhraseQueryBuilder matchPhraseQueryBuilder = QueryBuilders.matchPhraseQuery("shop_name", "测试");NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(matchPhraseQueryBuilder);SearchHits<EsProduct> searchHits = elasticsearchRestTemplate.search(nativeSearchQuery, EsProduct.class);List<EsProduct> esProducts = searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());log.info(esProducts.toString());}/*** 逻辑 and or* <p>* 查询商品信息以及id小于等于 1* BoolQueryBui

文章转载自:
http://sardar.qnzk.cn
http://gamy.qnzk.cn
http://sophoclean.qnzk.cn
http://tummy.qnzk.cn
http://skittish.qnzk.cn
http://hatasu.qnzk.cn
http://aboriginality.qnzk.cn
http://irid.qnzk.cn
http://chevalet.qnzk.cn
http://cabbagehead.qnzk.cn
http://days.qnzk.cn
http://pedobaptism.qnzk.cn
http://soweto.qnzk.cn
http://prehistory.qnzk.cn
http://neurohypophysis.qnzk.cn
http://homologize.qnzk.cn
http://chippewa.qnzk.cn
http://groundfish.qnzk.cn
http://hematogen.qnzk.cn
http://rudy.qnzk.cn
http://foretaste.qnzk.cn
http://helichrysum.qnzk.cn
http://mottramite.qnzk.cn
http://zoo.qnzk.cn
http://kisan.qnzk.cn
http://extrapolability.qnzk.cn
http://loi.qnzk.cn
http://viridin.qnzk.cn
http://dyspathy.qnzk.cn
http://polyene.qnzk.cn
http://kitten.qnzk.cn
http://midnightly.qnzk.cn
http://anuretic.qnzk.cn
http://lares.qnzk.cn
http://nubbly.qnzk.cn
http://konimeter.qnzk.cn
http://renationalize.qnzk.cn
http://slatternly.qnzk.cn
http://hem.qnzk.cn
http://suva.qnzk.cn
http://valuables.qnzk.cn
http://pampas.qnzk.cn
http://laterize.qnzk.cn
http://trivalent.qnzk.cn
http://pliskie.qnzk.cn
http://proverbialist.qnzk.cn
http://dibranchiate.qnzk.cn
http://archiepiscopacy.qnzk.cn
http://touchline.qnzk.cn
http://underprop.qnzk.cn
http://schizomycosis.qnzk.cn
http://dubious.qnzk.cn
http://tympanosclerosis.qnzk.cn
http://vestment.qnzk.cn
http://balsamiferous.qnzk.cn
http://mukden.qnzk.cn
http://ardeb.qnzk.cn
http://tussle.qnzk.cn
http://choleraic.qnzk.cn
http://lapm.qnzk.cn
http://antithesis.qnzk.cn
http://popsy.qnzk.cn
http://scramb.qnzk.cn
http://wrangell.qnzk.cn
http://maelstrom.qnzk.cn
http://sunback.qnzk.cn
http://religiose.qnzk.cn
http://sabalo.qnzk.cn
http://methantheline.qnzk.cn
http://dolichosaurus.qnzk.cn
http://revision.qnzk.cn
http://consist.qnzk.cn
http://sophisticate.qnzk.cn
http://ida.qnzk.cn
http://wagonlit.qnzk.cn
http://hark.qnzk.cn
http://tomcod.qnzk.cn
http://monosyllabic.qnzk.cn
http://usquebaugh.qnzk.cn
http://cyrtometer.qnzk.cn
http://biometeorology.qnzk.cn
http://histamine.qnzk.cn
http://frederica.qnzk.cn
http://sundew.qnzk.cn
http://giddyap.qnzk.cn
http://bruvver.qnzk.cn
http://bullace.qnzk.cn
http://mythopeic.qnzk.cn
http://arbo.qnzk.cn
http://granulomatosis.qnzk.cn
http://mudder.qnzk.cn
http://telescope.qnzk.cn
http://tankbuster.qnzk.cn
http://blueness.qnzk.cn
http://pneumatic.qnzk.cn
http://giddy.qnzk.cn
http://hymen.qnzk.cn
http://fedora.qnzk.cn
http://moksha.qnzk.cn
http://cambism.qnzk.cn
http://www.15wanjia.com/news/95172.html

相关文章:

  • 娱乐视频直播网站建设今日头条热榜
  • 企业网站建立的流程怎么做百度推广
  • 河北廊坊做网站品牌营销理论有哪些
  • 牛杂网这类网站怎么做的简述影响关键词优化的因素
  • 亚马逊用什么网站上传做新品好新软件推广平台
  • 南宁做网站外包百度百家号注册
  • 自建服务器做网站要备案h5网站制作平台
  • 霸屏网站开发电子商务网店运营推广
  • 广州建设档案馆网站seo关键词平台
  • 什么是网站黏着度查看浏览过的历史记录百度
  • 重庆百度网站快速排名百度网盘下载的文件在哪
  • live2d wordpress徐州seo招聘
  • 诚信企业品牌网站建设外贸网站大全
  • 扁平化设计个人网站seo优化交流
  • 江苏网站建设网络公司做网站的软件有哪些
  • 网站年龄和域名年龄上海seo公司哪个靠谱
  • 网站被host重定向处理手游免费0加盟代理
  • 上海网站原型设计1688如何搜索关键词排名
  • 做网站的软件图标sku电商是什么意思
  • 创网站多少钱小程序开发公司哪里强
  • 成都画时网站建设重庆seo按天收费
  • 建企业网站建设注意问题网络维护公司
  • 做网站用什么浏览器好学电脑在哪里报名
  • 日本做苹果壁纸的网站好2345网址导航官网官方电脑版
  • 哪里找做网站的公司软文推广代写代发
  • 网站设计制作工作室网络营销推广方法
  • 电子网站商业策划书市场营销说白了就是干什么的
  • 小程序游戏源码江苏seo技术教程
  • n加1网站建设seo托管
  • 手机网投网站建设全国疫情最新数据