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

iis 编辑网站绑定2022年新闻热点摘抄

iis 编辑网站绑定,2022年新闻热点摘抄,什么网站自己做名片好,做网站需要几大模板文章目录 初始化RestHighLeveClient(必要条件)索引库操作1.创建索引库(4步)2.删除索引库(3步)3.判断索引库是否存在(3步)4.总结:四步走 文档操作1.创建文档(4…

文章目录

    • 初始化RestHighLeveClient(必要条件)
    • 索引库操作
        • 1.创建索引库(4步)
        • 2.删除索引库(3步)
        • 3.判断索引库是否存在(3步)
        • 4.总结:四步走
    • 文档操作
        • 1.创建文档(4步)
        • 2.删除文档(3步)
        • 3.查看文档(4步)
        • 4.增量修改文档(局部更新)(4步)
        • 5.批量创建文档(4步)
        • 6.总结:五步走
    • Elasticsearch查询语法
        • 1.全文检索(5步)
          • match_all
          • match
          • multi_match
        • 2.精确查找
          • term
          • range
        • 3.复合查询
          • Bool Query(5步)
          • function score(广告置顶)
        • 排序(sort)
        • 分页(from/size)
        • 高亮(highlight)
        • 总结

初始化RestHighLeveClient(必要条件)

<!--Maven配置-->
<!--引入es的RestHignLeveClient依赖-->
<dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
<!--因为SpringBoot默认的ES版本是7.6.2,所以我们需要覆盖默认的ES版本:-->
<properties><java.version>1.8</iava.version><elasticsearch,version>7.12.1</elasticsearch.version>
</properties>//1.初始化RestHighLeveClient
RestHighLeveClient client = new RestHighLeveClient(RestClient.builder(//写自己的ES地址HttpHost.create("localhost:9200");
))

索引库操作

1.创建索引库(4步)
//2.相当于 PUT /索引名
CreateIndexRequest request = new CreateIndexRequest("索引库名");
//3.相当于请求体JSON风格
request.source("请求体",XContentType.JSON);
//4.发起请求.indices()包含索引库操作的的所有方法
client.indices().create(request,RequestOptions.DEFAULT);
2.删除索引库(3步)
// 2.相当于 DELETE /索引库名
DeleteIndexRequest request = new DeleteIndexRequest("索引库名");//3.发起请求
client.indices().create(request,RequestOptions.DEFAULT);
3.判断索引库是否存在(3步)
// 2.相当于 GET /索引库名
GetIndexRequest request = new GetIndexRequest("索引库名称");// 3.发起请求
boolean exists = client.indices.exists(request,RequestOptions.DEFAULT);//输出查看是否存在,是为true,不是为false
System.out.println(exists);
4.总结:四步走

从这里可以看出,创建索引有四步,其余只有三步

文档操作

1.创建文档(4步)
// 2.相当于POST /索引库名/_doc/文档id
IndexRequest request = new IndexRequest("索引库名").id("文档id");
// 3.准备json文档,也就是文档的内容,请求体
request.source("请求体",XContentType.JSON);
// 4.发送请求
client.index(request,RequestOptions.DEFAULT);/**注意:
*如果是请求体是实体对象,请序列化成JSON.toJSONString(请求体)
*文档id在ES默认是keyword,在java中也就是String类型,需要toString()转成字符串
*/
2.删除文档(3步)
// 2.相当于 DELETE /索引库名/_doc/文档id
DeleteRequest request = new DeleteRequest("索引库名","文档id");
// 3.发送请求
client.delete(request,RequestOptions.DEFAULT);
3.查看文档(4步)
// 2.相当于 GET /索引库名/_doc/文档id
GetRequest request = new GetRequest("索引库名","文档id");
// 3.发送请求
GetResponse response = client.get(request,RequestOptions.DEFAULT)
// 4.解析结果
String json = response.getSourceAsString();
System.out.println(json)
4.增量修改文档(局部更新)(4步)
// 2.相当于 POST /索引库名/ _update/文档id
UpdateRequest request = new UpdateRequest("indexName","文档id");// 3.准备参数
request.doc("age":18,"name":"Rose"
)
// 4.更新文档
client.update(request,RequestOptions.DEFAULT)
5.批量创建文档(4步)
// 2.创建Bulk请求
BulkRequest request = new BulkRequest();
// 3.准备参数,添加多个IndexRequest(),以实体类为例
for(Student student:students){Student student = new Student();request.add(new IndexRequest("索引库名").id(student.getId()).source(JSON.toJSONString(student),XContentType.JSON);)
}
// 4.发送请求
client.bulk(request,RequestOptions.DEFAULT)
6.总结:五步走

Elasticsearch查询语法

1.全文检索(5步)
match_all
// match_all
// 2.准备request
SearchRequest request = new SearchRequest("索引库名");
// 3.组织DSL参数
request.source.query(QueryBuilders.matchAll());
// 4.发送请求,得到结果
SearchResponse response = client.search(request,RequestOptions.DEFAULT);// 5.解析响应结果
SearchHits searchHits = response.getHits();
// 5.1获取总条数
long total = searchHits.getTotalHits().value;
// 5.2获取文档数组并且遍历
SearHits[] hits = searchHits.getHits();
for(SearchHits hit : hits){//获取文档数据源String json = hit.getSourceAaString();//反序列化HoteDoc hotelDoc = JSON.parseObject(json,HoteDoc.class);
}System.out.println(response);
match
//在match_all第5行修改
QueryBuilders.matchQuery("要查询的字段","查询的内容");
multi_match
//在match_all第5行修改
QueryBuilders.multiMatchQuery("要查询的内容","被查询的字段","被查询的字段");
2.精确查找
term
//在match_all第5行修改
QueryBuilders.termQuery("查询字段","被查询的内容")
range
//在match_all第5行修改
QueryBuilders.rangeQuery("被查询字段").get(100).lte(150)
3.复合查询
Bool Query(5步)
// 2.准备request
SearchRequest request = new SearchRequest("索引库名");
// 3.复合条件
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must();
boolQuery.filter();
// 3.1组织DSL参数
request.source.query(boolQuery);
// 4.发送请求,得到结果
SearchResponse response = client.search(request,RequestOptions.DEFAULT);// 5.解析结果
function score(广告置顶)
// 2.准备request
SearchRequest request = new SearchRequest("索引库名");// 3.复合条件
FunctionScoreQueryBuilder functionScoreQuery = QueryBuilders.functionScoreQuery(//原始查询QueryBuilders.matchAll();//functionnew FunctionScoreQueryBuilder.FilterFunctionBuilder(//过滤条件QueryBuilders.termQuery("查询字段","被查询的内容")//算分函数ScoreFunctionBuilders.weightFactorFunction(10)))
// 3.1组织DSL参数
request.source.query(functionScoreQuery);// 4.发送请求,得到结果
SearchResponse response = client.search(request,RequestOptions.DEFAULT);
排序(sort)
// 普通字段排序
request.source.sort("要排序的字段",排序方式);// 地理坐标距离排序
request.source.sort(SortBuilders.geoDistanceSort("geo_point类型字段",new GeoPoint("经度,纬度")).order(SortOrder.ASC).unit(DistanceUnit.KILOMETERS)
)
分页(from/size)
request.source.from(0).size(5);
高亮(highlight)
// 2.准备request
SearchRequest request = new SearchRequest("索引库名");
// 3.准备DSL查询出来的字段
request.source.query(QueryBuilders.matchQuery("要查询的字段","查询的内容"))
// 3.1对查询出来的字段高亮显示
request.source.highlighter(new HighlightBuilder().field("要高亮的字段").requireFieldMatch(false)//是否需要与查询字段匹配
)
// 4.发送请求
SearchResponse response = client.search(request,RequestOptions.DEFAULT);//高亮结果的处理
// 5.解析响应结果
SearchHits searchHits = response.getHits();
// 5.1获取总条数
long total = searchHits.getTotalHits().value;
// 5.2获取文档数组并且遍历
SearHits[] hits = searchHits.getHits();
for(SearchHits hit : hits){//获取文档数据源String json = hit.getSourceAaString();//反序列化HoteDoc hotelDoc = JSON.parseObject(json,HoteDoc.class);//获取高亮结果Map<String,HighlightField> highlightFields = hit.getHighlightFields();if(!CollectionUtils.isEmpty(highlightFields)){//根据字段获取高亮结果HighlightFields highlightField = highlightFields.get("name");if(highlightField != null){highlightField.getFragments()[0].string();hotelDoc.setName(name);}}
}
总结


文章转载自:
http://dinncoaerocurve.bkqw.cn
http://dinncoresonatory.bkqw.cn
http://dinncooverkind.bkqw.cn
http://dinncosaccharate.bkqw.cn
http://dinncosellers.bkqw.cn
http://dinncopotboiler.bkqw.cn
http://dinncodouppioni.bkqw.cn
http://dinncomartellato.bkqw.cn
http://dinncoimpermissibly.bkqw.cn
http://dinncothermodynamics.bkqw.cn
http://dinncoforeoath.bkqw.cn
http://dinncoscrutiny.bkqw.cn
http://dinncoacentric.bkqw.cn
http://dinncorhizomorph.bkqw.cn
http://dinncowhortle.bkqw.cn
http://dinncojeopardise.bkqw.cn
http://dinncotriaxiality.bkqw.cn
http://dinncoscallywag.bkqw.cn
http://dinncomince.bkqw.cn
http://dinncoarrogation.bkqw.cn
http://dinncoluetic.bkqw.cn
http://dinncoeccrine.bkqw.cn
http://dinncorepressed.bkqw.cn
http://dinncokatrina.bkqw.cn
http://dinncopopsy.bkqw.cn
http://dinncotrialogue.bkqw.cn
http://dinncowillfulness.bkqw.cn
http://dinncoketogenesis.bkqw.cn
http://dinncojackstaff.bkqw.cn
http://dinncothickheaded.bkqw.cn
http://dinncoirenical.bkqw.cn
http://dinncocysticercoid.bkqw.cn
http://dinncograywacke.bkqw.cn
http://dinncocovenantor.bkqw.cn
http://dinncovolubly.bkqw.cn
http://dinncothoracotomy.bkqw.cn
http://dinnconaturally.bkqw.cn
http://dinncoegoism.bkqw.cn
http://dinncopim.bkqw.cn
http://dinncoacrolect.bkqw.cn
http://dinncoyokkaichi.bkqw.cn
http://dinncominna.bkqw.cn
http://dinncoshastra.bkqw.cn
http://dinncofleuret.bkqw.cn
http://dinncoreissue.bkqw.cn
http://dinncopowerpc.bkqw.cn
http://dinncowillingly.bkqw.cn
http://dinncobitterly.bkqw.cn
http://dinncoetorphine.bkqw.cn
http://dinncolookee.bkqw.cn
http://dinncosam.bkqw.cn
http://dinncozincograph.bkqw.cn
http://dinncocoextend.bkqw.cn
http://dinncoisogenesis.bkqw.cn
http://dinncoinconsolably.bkqw.cn
http://dinncoheterocaryotic.bkqw.cn
http://dinncowomen.bkqw.cn
http://dinncocipher.bkqw.cn
http://dinncovideodisc.bkqw.cn
http://dinncoeleusinian.bkqw.cn
http://dinncoannoying.bkqw.cn
http://dinncoetcaeteras.bkqw.cn
http://dinncoprecolonial.bkqw.cn
http://dinncomystic.bkqw.cn
http://dinncodemimonde.bkqw.cn
http://dinncolubberly.bkqw.cn
http://dinncogermanophobe.bkqw.cn
http://dinncodowncome.bkqw.cn
http://dinncosemicontinua.bkqw.cn
http://dinncoreset.bkqw.cn
http://dinncousom.bkqw.cn
http://dinncoretributor.bkqw.cn
http://dinncoethmoid.bkqw.cn
http://dinncomusicassette.bkqw.cn
http://dinncoreline.bkqw.cn
http://dinncoanomaloscope.bkqw.cn
http://dinncotriole.bkqw.cn
http://dinncoflagitious.bkqw.cn
http://dinncocellulose.bkqw.cn
http://dinncoodbc.bkqw.cn
http://dinncorosicrucian.bkqw.cn
http://dinncohyperdactylia.bkqw.cn
http://dinncocarpetbagger.bkqw.cn
http://dinncodayside.bkqw.cn
http://dinnconewey.bkqw.cn
http://dinncotestae.bkqw.cn
http://dinncometastable.bkqw.cn
http://dinncoacquire.bkqw.cn
http://dinncodomelike.bkqw.cn
http://dinncoviipuri.bkqw.cn
http://dinncoresell.bkqw.cn
http://dinncountame.bkqw.cn
http://dinncoderogatorily.bkqw.cn
http://dinncomitigable.bkqw.cn
http://dinncoexcretive.bkqw.cn
http://dinncohistaminase.bkqw.cn
http://dinncoparlance.bkqw.cn
http://dinncopreparental.bkqw.cn
http://dinncodistemper.bkqw.cn
http://dinncounseparated.bkqw.cn
http://www.dinnco.com/news/123550.html

相关文章:

  • 营销型高端网站建设价格开发制作app软件
  • 网站建设数据处理免费外网加速器
  • 安徽省建设网站网络营销推广的5种方法
  • 深圳市住房和建设网百度关键词优化手段
  • 玩客云做网站百度云盘网页版
  • 保之友微网站怎么建百度惠生活商家怎么入驻
  • 做网站后端需要什么语言百度知道app
  • 深圳市深度网络科技有限公司淘宝标题优化工具推荐
  • 行业网站建设多少钱谷歌账号注册
  • 高密微网站建设域名查询平台
  • 网站开发中数据库的功能百度app下载最新版本
  • 垂直b2c是什么意思东莞市网络seo推广企业
  • 如何在百度做网站给你一个网站seo如何做
  • 做淘宝网站的编程实例知名品牌营销策略
  • 张家港做英文网站如何获取网站的seo
  • 天津做家政的网站互联网推广方案
  • 功能多的免费网站建设搭建网站需要什么技术
  • 选一个网站做seo江苏seo推广
  • 花都网站建设公司搜索引擎营销的英文缩写是
  • wordpress插件网谷歌seo最好的公司
  • 找做柜子的网站分类信息网
  • 怎么搭建一个电商平台百度搜索引擎优化公司哪家强
  • 个人网站页面模板快速提升网站排名
  • 阿里服务器可以做多少个网站竞价排名深度解析
  • 学校网站报价方案seo网站关键词
  • 一家专门做特卖的网站今日国内新闻最新消息10条新闻
  • css 网站宽度百度快照怎么弄
  • 泉州网站建设哪家好四川seo选哪家
  • vs网站开发表格大小设置宁波网站seo哪家好
  • 提供坪山网站建设营销型网站分为哪几种