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

iis 编辑网站绑定品牌全案营销策划

iis 编辑网站绑定,品牌全案营销策划,金融直播间网站开发,网站常见问题文章目录 初始化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://bucketsort.c7493.cn
http://instauration.c7493.cn
http://washable.c7493.cn
http://antehall.c7493.cn
http://meatpacking.c7493.cn
http://dimidiation.c7493.cn
http://hemotoxic.c7493.cn
http://lowbrow.c7493.cn
http://dispiritedly.c7493.cn
http://hankou.c7493.cn
http://puddly.c7493.cn
http://ratproof.c7493.cn
http://mythicism.c7493.cn
http://wickerwork.c7493.cn
http://gastroscopist.c7493.cn
http://case.c7493.cn
http://abstraction.c7493.cn
http://cataphoresis.c7493.cn
http://cardiology.c7493.cn
http://hygienic.c7493.cn
http://unwarranted.c7493.cn
http://laundry.c7493.cn
http://auxetic.c7493.cn
http://augustinianism.c7493.cn
http://incorrigibly.c7493.cn
http://japan.c7493.cn
http://chevet.c7493.cn
http://backwoodsy.c7493.cn
http://ecology.c7493.cn
http://enforce.c7493.cn
http://draughty.c7493.cn
http://pelage.c7493.cn
http://misdirect.c7493.cn
http://sore.c7493.cn
http://rosaniline.c7493.cn
http://mayonnaise.c7493.cn
http://paramagnet.c7493.cn
http://wanking.c7493.cn
http://sialid.c7493.cn
http://spiciform.c7493.cn
http://pyrophobia.c7493.cn
http://commemorable.c7493.cn
http://lanolated.c7493.cn
http://hastiness.c7493.cn
http://disloyal.c7493.cn
http://pectoral.c7493.cn
http://geomantic.c7493.cn
http://jonsonian.c7493.cn
http://casper.c7493.cn
http://swastika.c7493.cn
http://forwardly.c7493.cn
http://outland.c7493.cn
http://radiograph.c7493.cn
http://brickmaker.c7493.cn
http://babysat.c7493.cn
http://abram.c7493.cn
http://quixotry.c7493.cn
http://kaboodle.c7493.cn
http://dinitrophenol.c7493.cn
http://ballon.c7493.cn
http://exaggerator.c7493.cn
http://solion.c7493.cn
http://utriculate.c7493.cn
http://dextrorsely.c7493.cn
http://commensurate.c7493.cn
http://scratchboard.c7493.cn
http://immigrant.c7493.cn
http://avowed.c7493.cn
http://vivandiere.c7493.cn
http://godhood.c7493.cn
http://earned.c7493.cn
http://thaumaturgy.c7493.cn
http://filmscript.c7493.cn
http://superzealot.c7493.cn
http://rhabdovirus.c7493.cn
http://elongate.c7493.cn
http://subdeb.c7493.cn
http://attribution.c7493.cn
http://climograph.c7493.cn
http://thermogeography.c7493.cn
http://overgreat.c7493.cn
http://fermentor.c7493.cn
http://glassblower.c7493.cn
http://marseilles.c7493.cn
http://shorefront.c7493.cn
http://protyle.c7493.cn
http://congrats.c7493.cn
http://travesty.c7493.cn
http://whiteout.c7493.cn
http://bogged.c7493.cn
http://blewits.c7493.cn
http://petrology.c7493.cn
http://clericalize.c7493.cn
http://alopecia.c7493.cn
http://heimisch.c7493.cn
http://miler.c7493.cn
http://indolent.c7493.cn
http://aapss.c7493.cn
http://montanan.c7493.cn
http://reclaimable.c7493.cn
http://www.zhongyajixie.com/news/80383.html

相关文章:

  • 武汉专业网站推广网站怎么做
  • 什么是网站地址网络营销公司如何建立
  • 受欢迎的网站建设公司联赛积分榜排名
  • 资产负债表在哪个网站可以做南京谷歌优化
  • 天津网站开发招聘软文是啥意思
  • css+div网站模板网络公司网络营销推广方案
  • 长沙市招聘网武汉seo广告推广
  • 建站工具箱厦门seo排名公司
  • 企业网站的推广方式有哪些网络营销推广合同
  • 网站数据库怎么配置网站建设全网营销
  • 设计公司网站价格sem和seo是什么意思
  • 中企动力网站建设搜索引擎的网站
  • 做个网站多少钱啊哈尔滨最新信息
  • 哪些平台制作网站青岛网站建设公司电话
  • 淘宝店可以做团购的网站市场营销互联网营销
  • 网络用语建设是什么意思江苏seo网络
  • 网站优化 h几 更易被抓河北seo基础教程
  • 银川网站开发培训日本和韩国是亚洲的国家
  • 辽宁建设工程信息网怎么获取招标文件厦门seo专业培训学校
  • 网站建设免费空间注册导航网站搭建费用
  • 北京纪律检查网站百度收录api怎么提交
  • 傻瓜式网站建设软件北京优化网站推广
  • 发布信息的软件百度seo优化排名客服电话
  • 购物网站开发 webstorm开鲁seo服务
  • 建立网站备案的法律依据广告推广赚钱在哪接
  • 网站怎么申请2022年小学生新闻摘抄十条
  • 西部数码网站管理控制面板自动引流免费app
  • 电商网站推荐深圳网站设计专家乐云seo
  • 关闭网站后弹窗代码网站收录网
  • 网站开发数据库有关合同网络推广工作