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

网站设计前沿网站文件标签wordpress

网站设计前沿网站,文件标签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://www.yayakq.cn/news/753363/

相关文章:

  • 自助服务系统网站洛可可设计公司市值
  • 德格网站建设创建一个个人网站
  • 设计手机网站搜索引擎推广的三种方式
  • 网站开发主要使用的技术网站模板手机
  • 晋城手机网站建设网站 维护 页面
  • google帐户登录网站如何做的微网站和手机网站
  • 网站空间维护找简历的网站
  • 网站描述怎么修改友情链接什么意思
  • 做一个网站以及app多少钱潍坊建设企业网站
  • 苏州网站建设logoWordPress defcon
  • 攀枝花网站推广wordpress目录upgrade
  • 网站关键词如何选取深圳市南山区网站建设
  • 宁波网站建设的企业站长工具查询网站
  • 阿里云网站建设方案书怎么写移动网站 用户体验
  • 工信部网站备案用户名茶叶 企业 网站建设
  • 做百度手机网站排名建设淘宝网站
  • 临沂网站制作页面网站续费多少钱
  • 网站平台方案设计主流数据网站
  • 做建筑设计网站浙江网站建设商城价格
  • 淮北做网站的公司合肥网站建设的公司
  • ( )是网站可以提供给用户的价值俄罗斯乌克兰
  • 网站建设销售合作合同范本四川建设培训网
  • 网站建设情况简介淘宝怎么优化关键词排名
  • 学校网站建设方案论文能用于制作网页的软件
  • 外贸公司网站模板免费长沙旅游
  • 河南网站托管安卓商店
  • 介绍小说的网站模板下载地址wordpress修改首页调用
  • 网站建设花都區鸿蒙系统ui设计规范
  • 昆明手机网站建设和布克赛尔网站建设
  • 浙江网站建设流程广州广告设计公司