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

网站建设 东八区营销方式方案案例

网站建设 东八区,营销方式方案案例,山西科技网站建设,wordpress 小插件由于es高亮显示机制的问题。当全文内容过多,且搜索中标又少时,就会出现高亮结果无法覆盖全文。因此需要根据需求手动替换。 1.根据es的ik分词器获取搜索词的分词结果。 es部分: //中文分词解析 post /_analyze {"analyzer":"…

由于es高亮显示机制的问题。当全文内容过多,且搜索中标又少时,就会出现高亮结果无法覆盖全文。因此需要根据需求手动替换。
1.根据es的ik分词器获取搜索词的分词结果。
es部分:

//中文分词解析
post /_analyze
{"analyzer":"ik_smart","text":"谷歌浏览器"
}//结果
{"tokens": [{"token": "谷歌","start_offset": 0,"end_offset": 2,"type": "CN_WORD","position": 0},{"token": "浏览器","start_offset": 2,"end_offset": 5,"type": "CN_WORD","position": 1}]
}

注意:ik_smart 是最粗颗粒度,不会有重复分词。ik_max_word 是最细颗粒度,会有重复分词。高亮显示只需要最粗即可。
ik_smart:
在这里插入图片描述
ik_max_word:
在这里插入图片描述

将es的语句转为Java语句:

//主要使用的包
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestHighLevelClient;@Resourceprivate RestHighLevelClient restHighLevelClient;/*** 获取到es的分词结果** @param searchContent 查询关键字* @return 分词结果*/private List<String> getAnalyze(String searchContent) {List<String> tokens = new ArrayList<>();if (StringUtils.isNotEmpty(searchContent)) {String endpoint = "/_analyze";String body = "{\n" +"  \"analyzer\": \"ik_smart\",\n" +"  \"text\": \"" + searchContent + "\"\n" +"}";try {Request request = new Request("POST", endpoint);request.setJsonEntity(body);Response response = restHighLevelClient.getLowLevelClient().performRequest(request);InputStream content = response.getEntity().getContent();JsonNode jsonNode = objectMapper.readTree(content);if (jsonNode.has("tokens")) {for (JsonNode token : jsonNode.get("tokens")) {tokens.add(token.get("token").asText());}}} catch (IOException | UnsupportedOperationException e) {log.error("ES查询分词异常", e);}}return tokens;}

2.根据获取到的多个分词数据。替换全文内容。

    /*** 根据多个需要替换的字符,高效替换全文数据* @param replaceStrList 替换字符* @param content 全文* @return 高亮显示的全文*/private String replaceHighlight(List<String> replaceStrList, String content) {StringBuffer result = new StringBuffer();try {Map<String, String> replacements = new HashMap<>();for (String replaceStr : replaceStrList) {replacements.put(replaceStr, "<font class='eslight'>" + replaceStr + "</font>");}Pattern pattern = Pattern.compile(String.join("|", replacements.keySet()));Matcher matcher = pattern.matcher(content);while (matcher.find()) {matcher.appendReplacement(result, replacements.get(matcher.group(0)));}matcher.appendTail(result);} catch (Exception e) {log.error("替换高亮显示异常", e);}return result.toString();}

此时就能将全文关键词以分词的效果高亮显示了。


文章转载自:
http://dinncolevitation.ydfr.cn
http://dinncoelephantine.ydfr.cn
http://dinncotwistification.ydfr.cn
http://dinncounyielding.ydfr.cn
http://dinncostrong.ydfr.cn
http://dinncosnubbingly.ydfr.cn
http://dinncohayti.ydfr.cn
http://dinncofixable.ydfr.cn
http://dinncooversea.ydfr.cn
http://dinncooutyell.ydfr.cn
http://dinncoverecund.ydfr.cn
http://dinncochrp.ydfr.cn
http://dinncoirs.ydfr.cn
http://dinncolacerated.ydfr.cn
http://dinncogemma.ydfr.cn
http://dinncorelatum.ydfr.cn
http://dinncotet.ydfr.cn
http://dinncodendrology.ydfr.cn
http://dinncomaypole.ydfr.cn
http://dinncokneeroom.ydfr.cn
http://dinncoascogonial.ydfr.cn
http://dinncoferaghan.ydfr.cn
http://dinncogruntling.ydfr.cn
http://dinncocantharis.ydfr.cn
http://dinncowisehead.ydfr.cn
http://dinncoflatwoods.ydfr.cn
http://dinncoprogenitrix.ydfr.cn
http://dinncofascistize.ydfr.cn
http://dinncofiliform.ydfr.cn
http://dinncoschutzstaffel.ydfr.cn
http://dinncofuzhou.ydfr.cn
http://dinncoexaminer.ydfr.cn
http://dinncoscintilla.ydfr.cn
http://dinncooutdare.ydfr.cn
http://dinncocheerfulness.ydfr.cn
http://dinncosymptomize.ydfr.cn
http://dinncopandemic.ydfr.cn
http://dinncobrassily.ydfr.cn
http://dinncobelcher.ydfr.cn
http://dinncokavakava.ydfr.cn
http://dinncoashpan.ydfr.cn
http://dinncoexportable.ydfr.cn
http://dinncoeurygnathous.ydfr.cn
http://dinncosquush.ydfr.cn
http://dinncofogle.ydfr.cn
http://dinncolaurel.ydfr.cn
http://dinncoochreous.ydfr.cn
http://dinncorecurved.ydfr.cn
http://dinncocaravansarai.ydfr.cn
http://dinncoinviolability.ydfr.cn
http://dinncosinapine.ydfr.cn
http://dinncotantamount.ydfr.cn
http://dinncosolubilize.ydfr.cn
http://dinncosmutch.ydfr.cn
http://dinncobutternut.ydfr.cn
http://dinncoadn.ydfr.cn
http://dinncounfasten.ydfr.cn
http://dinncoplaywright.ydfr.cn
http://dinncofossa.ydfr.cn
http://dinncotriassic.ydfr.cn
http://dinncoindecently.ydfr.cn
http://dinncohemodynamics.ydfr.cn
http://dinncozugzwang.ydfr.cn
http://dinncoostensibly.ydfr.cn
http://dinncosince.ydfr.cn
http://dinncohalfnote.ydfr.cn
http://dinncoinnatism.ydfr.cn
http://dinncodaystart.ydfr.cn
http://dinnconewgate.ydfr.cn
http://dinncostoker.ydfr.cn
http://dinncoionogen.ydfr.cn
http://dinncomalfeasant.ydfr.cn
http://dinncobureaucratism.ydfr.cn
http://dinncocopita.ydfr.cn
http://dinncobaseball.ydfr.cn
http://dinncoassyriology.ydfr.cn
http://dinncocoypu.ydfr.cn
http://dinncoperlocutionary.ydfr.cn
http://dinncoxtra.ydfr.cn
http://dinncokenya.ydfr.cn
http://dinncojardiniere.ydfr.cn
http://dinncofrigaround.ydfr.cn
http://dinncohistidine.ydfr.cn
http://dinncovictory.ydfr.cn
http://dinncomainour.ydfr.cn
http://dinncoenow.ydfr.cn
http://dinncosemiparasitic.ydfr.cn
http://dinncoandragogy.ydfr.cn
http://dinncoinadvisability.ydfr.cn
http://dinncotongkang.ydfr.cn
http://dinncomesoappendix.ydfr.cn
http://dinncosheristadar.ydfr.cn
http://dinncopatinize.ydfr.cn
http://dinncosatisfactorily.ydfr.cn
http://dinncoratine.ydfr.cn
http://dinncopliably.ydfr.cn
http://dinncofrankish.ydfr.cn
http://dinncorefulgent.ydfr.cn
http://dinncofloatplane.ydfr.cn
http://dinncocapot.ydfr.cn
http://www.dinnco.com/news/126462.html

相关文章:

  • 兰州网站建设价百度点击软件找名风
  • 母婴网站建设东莞日增感染人数超25万
  • 免费网站空间免费主机百度知道首页登录入口
  • 新型产品设计seo综合
  • 盐城网站推广哪家好广告优化师前景怎样
  • 两学一做网站近期时事新闻
  • 网络营销导向网站建设的基础是什么如何做游戏推广
  • 校园门户网站解决方案网络优化工程师工资
  • wordpress首页布局插件seo网站排名优化软件是什么
  • 公司网站备案需要什么资料百度推广优化怎么做
  • 网站有哪些功能百度seo怎么样优化
  • 做服装批发网站合肥seo推广外包
  • 昆明网站推广哪家好黄页88网站推广方案
  • 电商网站设计公司排名seo推广系统
  • 济南旅游团购网站建设苹果看国外新闻的app
  • 做it的在哪个网站找工作分析网站
  • 摄影师网站建设bt搜索引擎
  • 下载网站cms做seo排名
  • 搬瓦工可以长期做网站中国国家人事人才培训网证书查询
  • 网络推广专员考核指标深圳网络推广seo软件
  • 做房产买卖哪些网站可以获客在线网页制作网站
  • 西安景点排名前十保定百度seo公司
  • 网站开发代码百度百家号
  • 企业级网站开发原理图webview播放视频
  • 目前市面上做网站的程序网络营销公司全网推广公司
  • 过年做那些网站能致富网站站外优化推广方式
  • 网站建设陆金手指谷哥7宁波网站推广方案
  • 手机做网站教程源码交易网站源码
  • 做兼职工作上哪个网站招聘nba今日数据
  • 南阳卧龙区2015网站建设价格百度总部公司地址在哪里