当前位置: 首页>>代码示例>>Java>>正文


Java FunctionScoreQueryBuilder.FilterFunctionBuilder方法代码示例

本文整理汇总了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;
    }
 
开发者ID:codelibs,项目名称:fess-suggest,代码行数:25,代码来源:SuggestRequest.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:QueryDSLDocumentationTests.java

示例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);
}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:14,代码来源:FunctionsDemo.java

示例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();
}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:13,代码来源:FunctionScoreQueryDemo.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:QueryBuilders.java


注:本文中的org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。