Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage
This commit is contained in:
+83
-56
@@ -448,39 +448,23 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
Map<String,Object> mapHighlight1 = new HashMap<>();
|
||||
//封装首次的条件
|
||||
if (StringUtils.isNotBlank(selectValue)) {
|
||||
selectValue = selectValue.toLowerCase();
|
||||
|
||||
for (String field : fieldList) {
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
if("serial_number".equals(field)){
|
||||
map3.put("boost",1);
|
||||
}else if("title".equals(field)){
|
||||
map3.put("boost",1);
|
||||
}else if("file_text".equals(field)){
|
||||
map3.put("boost",0.01);
|
||||
}else if("content".equals(field)){
|
||||
map3.put("boost",0.01);
|
||||
}else if("file_name".equals(field)){
|
||||
map3.put("boost",1);
|
||||
}
|
||||
// 特殊处理编号字段
|
||||
if (field.equals("serial_number")){
|
||||
// map2放最内层
|
||||
map2.put(field, "*" + selectValue + "*");
|
||||
getQueryMapJsonFullText(queryMapJson, selectValue, field);
|
||||
|
||||
// map4放query
|
||||
map4.put("wildcard",map2);
|
||||
} else {
|
||||
map3.put("query",selectValue);
|
||||
// map3.put("minimum_should_match",2);
|
||||
|
||||
map2.put(field, map3);
|
||||
map4.put("match",map2);
|
||||
}
|
||||
queryMapJson.add(map4);
|
||||
//高亮
|
||||
if(!"flag".equals(field)){
|
||||
highlight(mapHighlight, field);
|
||||
} else {
|
||||
// query_string查询
|
||||
Map<String, Object> map25 = new HashMap<>();
|
||||
Map<String, Object> map45 = new HashMap<>();
|
||||
map25.put("query", selectValue);
|
||||
map25.put("allow_leading_wildcard", false); //禁用了前置通配符
|
||||
map45.put("query_string", map25);
|
||||
queryMapJson.add(map45);
|
||||
|
||||
}
|
||||
}
|
||||
mapHighlight1.put("fields",mapHighlight);
|
||||
@@ -491,39 +475,23 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
}
|
||||
//封装二次的条件
|
||||
if (StringUtils.isNotBlank(selectValueTwo)) {
|
||||
selectValueTwo = selectValueTwo.toLowerCase();
|
||||
|
||||
for (String field : fieldList) {
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
if("serial_number".equals(field)){
|
||||
map3.put("boost",1);
|
||||
}else if("title".equals(field)){
|
||||
map3.put("boost",1);
|
||||
}else if("file_text".equals(field)){
|
||||
map3.put("boost",0.01);
|
||||
}else if("content".equals(field)){
|
||||
map3.put("boost",0.01);
|
||||
}else if("file_name".equals(field)){
|
||||
map3.put("boost",1);
|
||||
}
|
||||
getQueryMapJsonFullText(queryMapJsonTwo, selectValueTwo, field);
|
||||
|
||||
//特殊处理编号字段
|
||||
if (field.equals("serial_number")){
|
||||
// map2放最内层
|
||||
map2.put(field, "*" + selectValueTwo + "*");
|
||||
// map4放query
|
||||
queryMap.put("wildcard",map2);
|
||||
} else {
|
||||
map3.put("query",selectValueTwo);
|
||||
// map3.put("minimum_should_match",2);
|
||||
map2.put(field, map3);
|
||||
queryMap.put("match", map2);
|
||||
}
|
||||
|
||||
queryMapJsonTwo.add(queryMap);
|
||||
//高亮
|
||||
if(!"flag".equals(field)){
|
||||
highlight(mapHighlight, field);
|
||||
} else {
|
||||
// query_string查询
|
||||
Map<String, Object> map25 = new HashMap<>();
|
||||
Map<String, Object> map45 = new HashMap<>();
|
||||
map25.put("query", selectValue);
|
||||
map25.put("allow_leading_wildcard", false); //禁用了前置通配符
|
||||
map45.put("query_string", map25);
|
||||
queryMapJson.add(map45);
|
||||
|
||||
}
|
||||
}
|
||||
mapHighlight1.put("fields",mapHighlight);
|
||||
@@ -576,6 +544,65 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
return page;
|
||||
}
|
||||
|
||||
private void getQueryMapJsonFullText(JSONArray queryMapJson, String selectValue, String field) {
|
||||
// 前缀匹配 缺点是前缀一定不能断开
|
||||
//情况举例:用户只记得前面那段字
|
||||
Map<String, Object> map21 = new HashMap<>();
|
||||
Map<String, Object> map31 = new HashMap<>();
|
||||
Map<String, Object> map41 = new HashMap<>();
|
||||
if("serial_number".equals(field)){
|
||||
map31.put("boost",1);
|
||||
}else if("title".equals(field)){
|
||||
map31.put("boost",1);
|
||||
}else if("file_text".equals(field)){
|
||||
map31.put("boost",0.01);
|
||||
}else if("content".equals(field)){
|
||||
map31.put("boost",0.01);
|
||||
}else if("file_name".equals(field)){
|
||||
map31.put("boost",1);
|
||||
}
|
||||
map31.put("value", selectValue);
|
||||
map21.put(field + ".keyword", map31);
|
||||
map41.put("prefix", map21);
|
||||
queryMapJson.add(map41);
|
||||
|
||||
// match_phrase_prefix 词组匹配查询,允许最后词组与文中的任意分词前缀匹配
|
||||
Map<String, Object> map22 = new HashMap<>();
|
||||
Map<String, Object> map32 = new HashMap<>();
|
||||
Map<String, Object> map42 = new HashMap<>();
|
||||
if("serial_number".equals(field)){
|
||||
map32.put("boost",1);
|
||||
}else if("title".equals(field)){
|
||||
map32.put("boost",1);
|
||||
}else if("file_text".equals(field)){
|
||||
map32.put("boost",0.01);
|
||||
}else if("content".equals(field)){
|
||||
map32.put("boost",0.01);
|
||||
}else if("file_name".equals(field)){
|
||||
map32.put("boost",1);
|
||||
}
|
||||
map32.put("query", selectValue);
|
||||
map22.put(field, map32);
|
||||
map42.put("match_phrase_prefix", map22);
|
||||
queryMapJson.add(map42);
|
||||
|
||||
// match分词匹配查询
|
||||
// 情况举例:用户可能他知道开头的前缀几个字,知道中间的几个字
|
||||
Map<String, Object> map23 = new HashMap<>();
|
||||
Map<String, Object> map43 = new HashMap<>();
|
||||
map23.put(field, selectValue);
|
||||
map43.put("match", map23);
|
||||
queryMapJson.add(map43);
|
||||
|
||||
// wildcard模糊查询
|
||||
//情况举例:用户只记得中间那段字
|
||||
Map<String, Object> map24 = new HashMap<>();
|
||||
Map<String, Object> map44 = new HashMap<>();
|
||||
map24.put(field, "*" + selectValue + "*");
|
||||
map44.put("wildcard",map24);
|
||||
queryMapJson.add(map44);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private IPage getiPage(String selectValue, String selectValueTwo, JSONArray queryMapJson,Map<String,Object> highlightMap,
|
||||
JSONArray should, Integer pageNo, Integer pageSize, String paragraphFlag,
|
||||
|
||||
@@ -781,7 +781,9 @@
|
||||
height: calc(100% - 100px);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/deep/ .ant-select-allow-clear{
|
||||
height: 30px;
|
||||
}
|
||||
.text {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user