From e2673761651641b10968fbf30884127384674a01 Mon Sep 17 00:00:00 2001 From: wangzhijiang <1358525938@qq.com> Date: Tue, 20 Jun 2023 16:07:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=AB=AF=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=B8=AD=E5=BF=83-=E6=96=87=E6=A1=A3=E5=BA=93=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=AE=8C=E5=96=84.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SearchCenterServiceImpl.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/phone/service/impl/SearchCenterServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/phone/service/impl/SearchCenterServiceImpl.java index c671c83d1..e2222fc1d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/phone/service/impl/SearchCenterServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/phone/service/impl/SearchCenterServiceImpl.java @@ -141,19 +141,43 @@ public class SearchCenterServiceImpl implements ISearchCenterService { fieldList.add("serial_number"); fieldList.add("title"); fieldList.add("content"); + fieldList.add("flag"); JSONArray queryMapJsonAll = new JSONArray(); + JSONArray queryJsonMustNot = new JSONArray(); JSONArray queryMapInputJson = new JSONArray(); Map mapHighlight = new HashMap<>(); Map mapHighlight1 = new HashMap<>(); String selectValue = (String) params.get("selectValue"); + if(StringUtils.isNotBlank(selectValue)){ + Map map = new HashMap<>(); + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + map.put("query",SEARCH_FLAG); + map1.put("flag",map); + map2.put("match",map1); + queryJsonMustNot.add(map2); + }else { + selectValue = SEARCH_FLAG; + } if (StringUtils.isNotBlank(selectValue)) { for (String field : fieldList) { this.setQueryMapJson(queryMapInputJson, selectValue, field); //高亮 - this.wdkHighlight(mapHighlight, field); + if(!"flag".equals(field)){ + this.wdkHighlight(mapHighlight, field); + } else { + // query_string查询 + Map map25 = new HashMap<>(); + Map map45 = new HashMap<>(); + map25.put("query", selectValue); + map25.put("fields", fieldList.toArray()); + map25.put("allow_leading_wildcard", false); //禁用了前置通配符 + map45.put("query_string", map25); + queryMapInputJson.add(map45); + } } mapHighlight1.put("fields", mapHighlight); @@ -197,7 +221,7 @@ public class SearchCenterServiceImpl implements ISearchCenterService { pageSize, cut, querySort, - null, + queryJsonMustNot, null ); return Result.OK(page);