mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
提交修改
This commit is contained in:
@@ -373,6 +373,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
|
|
||||||
if(StringUtils.isNotBlank(params.getKeywords())) {
|
if(StringUtils.isNotBlank(params.getKeywords())) {
|
||||||
|
|
||||||
|
|
||||||
String words=QueryParser.escape(params.getKeywords());
|
String words=QueryParser.escape(params.getKeywords());
|
||||||
|
|
||||||
// System.out.println(params.getKeywords());
|
// System.out.println(params.getKeywords());
|
||||||
@@ -380,9 +381,10 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
|
|
||||||
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
|
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
|
||||||
keywordQuery.should(QueryBuilders.wildcardQuery("name", "*"+words+"*").boost(9f));
|
keywordQuery.should(QueryBuilders.wildcardQuery("name", "*"+words+"*").boost(9f));
|
||||||
|
keywordQuery.should(QueryBuilders.wildcardQuery("teacher", "*"+words+"*").boost(7f));
|
||||||
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("name", 9f));//用此方法无法查询出有转义符的处理
|
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("name", 9f));//用此方法无法查询出有转义符的处理
|
||||||
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("teacher", 8f));
|
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("teacher", 8f));
|
||||||
keywordQuery.should(QueryBuilders.wildcardQuery("teacher", "*"+words+"*").boost(7f));
|
|
||||||
keywordQuery.minimumShouldMatch(1);
|
keywordQuery.minimumShouldMatch(1);
|
||||||
boolQuery.must(keywordQuery);
|
boolQuery.must(keywordQuery);
|
||||||
//boolQuery.must(QueryBuilders.wildcardQuery("name", "*"+params.getKeywords()+"*").boost(9f));
|
//boolQuery.must(QueryBuilders.wildcardQuery("name", "*"+params.getKeywords()+"*").boost(9f));
|
||||||
|
|||||||
Reference in New Issue
Block a user