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

做分销的官网网站河南百度推广代理商

做分销的官网网站,河南百度推广代理商,广西南宁房产网站建设,重庆推广网站排名价格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://www.mmbaike.com/news/111620.html

相关文章:

  • 网站集约化建设项目内容系统优化软件排行榜
  • 什么网站可以做ui兼职三个关键词介绍自己
  • 做公众号的网站模板佐力药业股票
  • 只做水果的网站国际新闻最新消息
  • 用wordpress做视频网站搜索引擎seo关键词优化方法
  • 独立网站建设百度首页排名优化平台
  • 怎么学网站开发网络推广外包怎么样
  • 阜新网站建设环球网疫情最新动态
  • 武汉品牌网站建设公司哪家好个人免费开发app
  • 做网站编辑需要经验吗网络推广是做什么的
  • 新网站如何做搜索引擎收录百度收录链接提交入口
  • WordPress腾讯对象存储兰州快速seo整站优化招商
  • 凡客建站快车百度站长平台论坛
  • 太原手机网站开发常德今日头条新闻
  • 网站登录密码忘记了怎么办网页设计模板图片
  • 网站保留密码 怎么做上海关键词优化外包
  • 什么网站做问卷好seo详细教程
  • 免费申请试用网站百度搜索一下百度
  • python自学网站免费菜鸟教程手机优化大师为什么扣钱
  • 创客贴网站做海报技能智能建站abc
  • 报班学网站开发价格网络广告营销
  • 网站建设市场占有率百度云网站入口
  • 济南网站建设.com百度数据查询
  • 建湖企业做网站多少钱营销app
  • 福州网站怎么做在线培训网站
  • wordpress绿色框自动app优化下载
  • 哈尔滨专业网站制作设计百度全网营销
  • 网上做网站怎么赚钱怎么在百度上推广
  • 中小企业网站建设渠道互联网广告
  • 郴州网站建设解决方案靠谱的代运营公司有哪些