...
|
...
|
@@ -15,10 +15,14 @@ import com.yoho.search.service.utils.HttpServletRequestUtils; |
|
|
import com.yoho.search.service.utils.SearchApiResultUtils;
|
|
|
import com.yoho.search.service.vo.SearchApiResult;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.elasticsearch.common.lucene.search.function.CombineFunction;
|
|
|
import org.elasticsearch.common.lucene.search.function.FieldValueFactorFunction;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.MatchQueryBuilder;
|
|
|
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
|
|
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
|
|
|
import org.elasticsearch.search.sort.SortBuilder;
|
|
|
import org.elasticsearch.search.sort.SortBuilders;
|
|
|
import org.elasticsearch.search.sort.SortOrder;
|
...
|
...
|
@@ -97,7 +101,11 @@ public class RobotQuestionServiceImpl extends BaseService implements IRobotQuest |
|
|
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
|
|
|
queryBuilder.minimumShouldMatch(minimumShouldMatch);
|
|
|
queryBuilder.field("question", 200).field("keywords", 100);
|
|
|
searchParam.setQuery(queryBuilder);
|
|
|
//权重字段影响打分,_score = _score + log(1 + 1 * questionSeq)
|
|
|
FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder);
|
|
|
functionScoreQueryBuilder.add(ScoreFunctionBuilders.fieldValueFactorFunction("questionSeq").modifier(FieldValueFactorFunction.Modifier.LOG1P).factor(1.0f));
|
|
|
functionScoreQueryBuilder.boostMode(CombineFunction.SUM);
|
|
|
searchParam.setQuery(functionScoreQueryBuilder);
|
|
|
|
|
|
//4.配置Filter
|
|
|
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
|
...
|
...
|
|