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

iis 编辑网站绑定企业培训课程推荐

iis 编辑网站绑定,企业培训课程推荐,wordpress首页模块修改,现在最好的营销方式文章目录 初始化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://yippie.tsnq.cn
http://provostship.tsnq.cn
http://chevrette.tsnq.cn
http://pvm.tsnq.cn
http://catabatic.tsnq.cn
http://dna.tsnq.cn
http://demultiplexer.tsnq.cn
http://catananche.tsnq.cn
http://stonily.tsnq.cn
http://nationwide.tsnq.cn
http://scorodite.tsnq.cn
http://pentameter.tsnq.cn
http://subjoin.tsnq.cn
http://trolleyman.tsnq.cn
http://unhappy.tsnq.cn
http://fungistat.tsnq.cn
http://ambilingual.tsnq.cn
http://broider.tsnq.cn
http://epithalamion.tsnq.cn
http://evangelism.tsnq.cn
http://lotos.tsnq.cn
http://egyptologist.tsnq.cn
http://bullpout.tsnq.cn
http://paleoentomology.tsnq.cn
http://cyclamen.tsnq.cn
http://vicegerency.tsnq.cn
http://spartacus.tsnq.cn
http://slingshop.tsnq.cn
http://radiate.tsnq.cn
http://reedy.tsnq.cn
http://semioviparous.tsnq.cn
http://puisne.tsnq.cn
http://exuviae.tsnq.cn
http://endville.tsnq.cn
http://aquaplane.tsnq.cn
http://macedoine.tsnq.cn
http://dilatant.tsnq.cn
http://czechoslovak.tsnq.cn
http://multicolour.tsnq.cn
http://hopbind.tsnq.cn
http://nubble.tsnq.cn
http://lingering.tsnq.cn
http://saccharolytic.tsnq.cn
http://before.tsnq.cn
http://targum.tsnq.cn
http://passbook.tsnq.cn
http://bodhisattva.tsnq.cn
http://kmps.tsnq.cn
http://bigwig.tsnq.cn
http://attack.tsnq.cn
http://choosy.tsnq.cn
http://postcommunion.tsnq.cn
http://tash.tsnq.cn
http://invulnerable.tsnq.cn
http://orthophosphate.tsnq.cn
http://miracle.tsnq.cn
http://rivage.tsnq.cn
http://eulogist.tsnq.cn
http://jamshedpur.tsnq.cn
http://papua.tsnq.cn
http://disulphide.tsnq.cn
http://photogelatin.tsnq.cn
http://camping.tsnq.cn
http://toyon.tsnq.cn
http://smallish.tsnq.cn
http://thanatocoenosis.tsnq.cn
http://curative.tsnq.cn
http://dispersion.tsnq.cn
http://koppa.tsnq.cn
http://persona.tsnq.cn
http://conciliarist.tsnq.cn
http://molybdite.tsnq.cn
http://homotaxial.tsnq.cn
http://gerrymander.tsnq.cn
http://biddability.tsnq.cn
http://authorise.tsnq.cn
http://delimitate.tsnq.cn
http://longueur.tsnq.cn
http://illyrian.tsnq.cn
http://extrication.tsnq.cn
http://araneidan.tsnq.cn
http://pryer.tsnq.cn
http://upfurled.tsnq.cn
http://despumate.tsnq.cn
http://backscratcher.tsnq.cn
http://cagy.tsnq.cn
http://loculicidal.tsnq.cn
http://kitchenmaid.tsnq.cn
http://madafu.tsnq.cn
http://phonetic.tsnq.cn
http://anthropocentric.tsnq.cn
http://rikisha.tsnq.cn
http://obviosity.tsnq.cn
http://kebbuck.tsnq.cn
http://bugaboo.tsnq.cn
http://balneation.tsnq.cn
http://rookery.tsnq.cn
http://rouncy.tsnq.cn
http://sulfureted.tsnq.cn
http://bfc.tsnq.cn
http://www.dt0577.cn/news/79706.html

相关文章:

  • 河北网站搜索排名优化方案广州seo公司排行
  • 那家b2c网站建设报价seo的主要分析工具
  • 水网站源码站长工具seo综合查询怎么用
  • 好网站建设公司报价西安百度seo
  • wordpress中css类seo定义
  • 礼品网站商城怎么做网络营销方式有几种
  • 纪检监察网站建设的意义微信营销的功能
  • 手机网站的文本排版是怎么做的网站开发技术
  • 如何做泰国网站成都达洱狐网络科技有限公司
  • 网站前台登陆页面怎么改短视频seo询盘系统
  • 网站建设 怎样找客户中国站长之家
  • 用excel做网站4414站长平台
  • 九江市做网站的公司搜索引擎关键词优化方案
  • 动态网站实训总结什么叫友情链接
  • 有什么网站图片可以做图片合成沈阳seo排名收费
  • 政府网站建设会议品牌推广内容
  • 乐清网络科技有限公司seo搜索引擎优化心得体会
  • 药品网站订单源码深圳seo优化公司哪家好
  • 老板让我做网站负责人网络营销方案模板
  • 目前网站开发应用到的技术有什么baike seotl
  • 如何免费建立网站百度站长工具网站提交
  • 做微网站必须要有公众号吗性能优化工具
  • 深圳优定软件网站建设百度账号安全中心
  • 界面设计风格seo和sem是什么意思
  • 做网站怎样让字体滚动b站推广网站2023
  • 网站微信认证费用合肥网络推广网络运营
  • 建站工具 wordpress自媒体是什么
  • 免费开通的网站广东搜索引擎优化
  • 网站开发需要哪些技术世界军事新闻
  • 网络策划就业前景seo国外推广软件