本文整理汇总了Java中org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionScoreQueryBuilder.FilterFunctionBuilder方法的具体用法?Java FunctionScoreQueryBuilder.FilterFunctionBuilder怎么用?Java FunctionScoreQueryBuilder.FilterFunctionBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder
的用法示例。
在下文中一共展示了FunctionScoreQueryBuilder.FilterFunctionBuilder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFunctionScoreQuery
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; //导入方法依赖的package包/类
protected QueryBuilder buildFunctionScoreQuery(final String query, final QueryBuilder queryBuilder) {
final List<FunctionScoreQueryBuilder.FilterFunctionBuilder> flist = new ArrayList<>();
if (isSingleWordQuery(query) && !isHiraganaQuery(query)) {
flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.prefixQuery(FieldNames.TEXT, query),
ScoreFunctionBuilders.weightFactorFunction(prefixMatchWeight)));
}
flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.fieldValueFactorFunction(FieldNames.DOC_FREQ)
.missing(0.1f).modifier(FieldValueFactorFunction.Modifier.LOG2P).setWeight(1.0F)));
flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.fieldValueFactorFunction(FieldNames.QUERY_FREQ)
.missing(0.1f).modifier(FieldValueFactorFunction.Modifier.LOG2P).setWeight(1.0F)));
flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.fieldValueFactorFunction(FieldNames.USER_BOOST)
.missing(1f).setWeight(1.0F)));
final FunctionScoreQueryBuilder functionScoreQueryBuilder =
QueryBuilders.functionScoreQuery(queryBuilder,
flist.toArray(new FunctionScoreQueryBuilder.FilterFunctionBuilder[flist.size()]));
functionScoreQueryBuilder.boostMode(CombineFunction.REPLACE);
functionScoreQueryBuilder.scoreMode(FunctionScoreQuery.ScoreMode.MULTIPLY);
return functionScoreQueryBuilder;
}
示例2: testFunctionScore
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; //导入方法依赖的package包/类
public void testFunctionScore() {
FilterFunctionBuilder[] functions = {
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
matchQuery("name", "kimchy"),
randomFunction("ABCDEF")),
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
exponentialDecayFunction("age", 0L, 1L))
};
functionScoreQuery(functions);
}
示例3: test
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
FunctionScoreQueryBuilder.FilterFunctionBuilder [] filterFunctionBuilders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[]
{
new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.scriptFunction("doc['pubTime'].value*0.00000000001")),
new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.scriptFunction("doc['opinionValue'].value*0.1")),
};
QueryBuilders.functionScoreQuery(
QueryBuilders.queryStringQuery("北京").defaultField("FIELD").field("titleZh^3.0"),
filterFunctionBuilders
).boostMode(CombineFunction.MULTIPLY).scoreMode(FiltersFunctionScoreQuery.ScoreMode.AVG);
}
示例4: testForClient
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; //导入方法依赖的package包/类
@Test
public void testForClient() throws Exception {
FunctionScoreQueryBuilder.FilterFunctionBuilder[] functions = {
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
QueryBuilders.matchQuery("name", "kimchy"),
ScoreFunctionBuilders. randomFunction("ABCDEF")),
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
ScoreFunctionBuilders.exponentialDecayFunction("age", 0L, 1L))
};
QueryBuilder qb = QueryBuilders.functionScoreQuery(functions);
client.prepareSearch().setQuery(qb).execute().actionGet();
}
示例5: functionScoreQuery
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; //导入方法依赖的package包/类
/**
* A query that allows to define a custom scoring function
*
* @param queryBuilder The query to custom score
* @param filterFunctionBuilders the filters and functions to execute
* @return the function score query
*/
public static FunctionScoreQueryBuilder functionScoreQuery(QueryBuilder queryBuilder, FunctionScoreQueryBuilder.FilterFunctionBuilder[] filterFunctionBuilders) {
return new FunctionScoreQueryBuilder(queryBuilder, filterFunctionBuilders);
}