org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder Java Examples

The following examples show how to use org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggingIT.java    From elasticsearch-learning-to-rank with Apache License 2.0 6 votes vote down vote up
public void prepareModelsExtraLogging() throws Exception {
    List<StoredFeature> features = new ArrayList<>(3);
    features.add(new StoredFeature("text_feature1", Collections.singletonList("query"), "mustache",
            QueryBuilders.matchQuery("field1", "{{query}}").toString()));
    features.add(new StoredFeature("text_feature2", Collections.singletonList("query"), "mustache",
            QueryBuilders.matchQuery("field2", "{{query}}").toString()));
    features.add(new StoredFeature("numeric_feature1", Collections.singletonList("query"), "mustache",
            new FunctionScoreQueryBuilder(QueryBuilders.matchAllQuery(), new FieldValueFactorFunctionBuilder("scorefield1")
                    .factor(FACTOR)
                    .modifier(FieldValueFactorFunction.Modifier.LN2P)
                    .missing(0F)).scoreMode(FunctionScoreQuery.ScoreMode.MULTIPLY).toString()));
    features.add(new StoredFeature("derived_feature", Collections.singletonList("query"), "derived_expression",
            "100"));
    features.add(new StoredFeature("extra_logging_feature", Arrays.asList("query"), ScriptFeature.TEMPLATE_LANGUAGE,
            "{\"lang\": \"native\", \"source\": \"feature_extractor_extra_logging\", \"params\": {}}"));

    StoredFeatureSet set = new StoredFeatureSet("my_set", features);
    addElement(set);
    StoredLtrModel model = new StoredLtrModel("my_model", set,
            new StoredLtrModel.LtrModelDefinition("model/linear",
                    LinearRankerParserTests.generateRandomModelString(set), true));
    addElement(model);
}
 
Example #2
Source File: BsRelatedContentCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<RelatedContentCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<RelatedContentCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    RelatedContentCQ cq = new RelatedContentCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            RelatedContentCQ cf = new RelatedContentCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #3
Source File: BsThumbnailQueueCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<ThumbnailQueueCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<ThumbnailQueueCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    ThumbnailQueueCQ cq = new ThumbnailQueueCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            ThumbnailQueueCQ cf = new ThumbnailQueueCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #4
Source File: UserServiceImpl.java    From springBoot-study with Apache License 2.0 6 votes vote down vote up
@Override
public List<User> searchUserByWeight(String searchContent) {
       // 根据权重进行查询
       FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery()
               .add(QueryBuilders.boolQuery().should(QueryBuilders.matchQuery("name", searchContent)),
                   ScoreFunctionBuilders.weightFactorFunction(10))
               .add(QueryBuilders.boolQuery().should(QueryBuilders.matchQuery("description", searchContent)),
                       ScoreFunctionBuilders.weightFactorFunction(100)).setMinScore(2);
       System.out.println("查询的语句:" + functionScoreQueryBuilder.toString());
       Iterable<User> searchResult = userDao.search(functionScoreQueryBuilder);
       Iterator<User> iterator = searchResult.iterator();
       List<User> list=new ArrayList<User>();
       while (iterator.hasNext()) {
    	   	list.add(iterator.next());
       }
       return list;
}
 
Example #5
Source File: BsWebAuthenticationCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<WebAuthenticationCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<WebAuthenticationCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    WebAuthenticationCQ cq = new WebAuthenticationCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            WebAuthenticationCQ cf = new WebAuthenticationCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #6
Source File: BsCrawlingInfoParamCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<CrawlingInfoParamCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<CrawlingInfoParamCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    CrawlingInfoParamCQ cq = new CrawlingInfoParamCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            CrawlingInfoParamCQ cf = new CrawlingInfoParamCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #7
Source File: BsRoleTypeCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<RoleTypeCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<RoleTypeCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    RoleTypeCQ cq = new RoleTypeCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            RoleTypeCQ cf = new RoleTypeCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #8
Source File: BsFileAuthenticationCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<FileAuthenticationCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<FileAuthenticationCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    FileAuthenticationCQ cq = new FileAuthenticationCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            FileAuthenticationCQ cf = new FileAuthenticationCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #9
Source File: BsBadWordCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<BadWordCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<BadWordCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    BadWordCQ cq = new BadWordCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            BadWordCQ cf = new BadWordCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #10
Source File: BsRelatedQueryCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<RelatedQueryCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<RelatedQueryCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    RelatedQueryCQ cq = new RelatedQueryCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            RelatedQueryCQ cf = new RelatedQueryCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #11
Source File: BsAccessTokenCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<AccessTokenCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<AccessTokenCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    AccessTokenCQ cq = new AccessTokenCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            AccessTokenCQ cf = new AccessTokenCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #12
Source File: BsScheduledJobCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<ScheduledJobCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<ScheduledJobCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    ScheduledJobCQ cq = new ScheduledJobCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            ScheduledJobCQ cf = new ScheduledJobCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #13
Source File: BsDataConfigCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<DataConfigCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<DataConfigCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    DataConfigCQ cq = new DataConfigCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            DataConfigCQ cf = new DataConfigCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #14
Source File: BsJobLogCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<JobLogCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<JobLogCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    JobLogCQ cq = new JobLogCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            JobLogCQ cf = new JobLogCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #15
Source File: LoggingIT.java    From elasticsearch-learning-to-rank with Apache License 2.0 6 votes vote down vote up
public void prepareModels() throws Exception {
    List<StoredFeature> features = new ArrayList<>(3);
    features.add(new StoredFeature("text_feature1", Collections.singletonList("query"), "mustache",
            QueryBuilders.matchQuery("field1", "{{query}}").toString()));
    features.add(new StoredFeature("text_feature2", Collections.singletonList("query"), "mustache",
            QueryBuilders.matchQuery("field2", "{{query}}").toString()));
    features.add(new StoredFeature("numeric_feature1", Collections.singletonList("query"), "mustache",
            new FunctionScoreQueryBuilder(QueryBuilders.matchAllQuery(), new FieldValueFactorFunctionBuilder("scorefield1")
                    .factor(FACTOR)
                    .modifier(FieldValueFactorFunction.Modifier.LN2P)
                    .missing(0F)).scoreMode(FunctionScoreQuery.ScoreMode.MULTIPLY).toString()));
    features.add(new StoredFeature("derived_feature", Collections.singletonList("query"), "derived_expression",
            "100"));

    StoredFeatureSet set = new StoredFeatureSet("my_set", features);
    addElement(set);
    StoredLtrModel model = new StoredLtrModel("my_model", set,
            new StoredLtrModel.LtrModelDefinition("model/linear",
                    LinearRankerParserTests.generateRandomModelString(set), true));
    addElement(model);
}
 
Example #16
Source File: BsWebConfigCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<WebConfigCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<WebConfigCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    WebConfigCQ cq = new WebConfigCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            WebConfigCQ cf = new WebConfigCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #17
Source File: BsElevateWordToLabelCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<ElevateWordToLabelCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<ElevateWordToLabelCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    ElevateWordToLabelCQ cq = new ElevateWordToLabelCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            ElevateWordToLabelCQ cf = new ElevateWordToLabelCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #18
Source File: IndexSearchDaoImpl.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the scripts and score function
 *
 * @param queryBuilder the query builder
 *
 * @return the function score query builder
 */
private FunctionScoreQueryBuilder getFunctionScoreQueryBuilder(QueryBuilder queryBuilder, String bdefActiveIndex)
{
    // Script for tag search score multiplier. If bdef set to tag search score multiplier else set to a default value.
    String inlineScript = "_score * (doc['_index'].value == '" + bdefActiveIndex + "' ? doc['" + BDEF_TAGS_SEARCH_SCORE_MULTIPLIER + "'].value : 1)";

    // Set the lang to painless
    Script script = new Script(ScriptType.INLINE, "painless", inlineScript, Collections.emptyMap());

    // Set the script
    ScriptScoreFunctionBuilder scoreFunction = ScoreFunctionBuilders.scriptFunction(script);

    // Create function score query builder
    return new FunctionScoreQueryBuilder(queryBuilder, scoreFunction);
}
 
Example #19
Source File: BsKeyMatchCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<KeyMatchCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<KeyMatchCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    KeyMatchCQ cq = new KeyMatchCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            KeyMatchCQ cf = new KeyMatchCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #20
Source File: BsDuplicateHostCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<DuplicateHostCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<DuplicateHostCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    DuplicateHostCQ cq = new DuplicateHostCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            DuplicateHostCQ cf = new DuplicateHostCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #21
Source File: BsElevateWordCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<ElevateWordCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<ElevateWordCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    ElevateWordCQ cq = new ElevateWordCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            ElevateWordCQ cf = new ElevateWordCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #22
Source File: BsCrawlingInfoCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<CrawlingInfoCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<CrawlingInfoCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    CrawlingInfoCQ cq = new CrawlingInfoCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            CrawlingInfoCQ cf = new CrawlingInfoCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #23
Source File: BsSearchLogCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<SearchLogCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<SearchLogCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    SearchLogCQ cq = new SearchLogCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            SearchLogCQ cf = new SearchLogCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #24
Source File: BsFavoriteLogCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<FavoriteLogCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<FavoriteLogCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    FavoriteLogCQ cq = new FavoriteLogCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            FavoriteLogCQ cf = new FavoriteLogCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #25
Source File: BsClickLogCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<ClickLogCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<ClickLogCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    ClickLogCQ cq = new ClickLogCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            ClickLogCQ cf = new ClickLogCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #26
Source File: BsUserInfoCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<UserInfoCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<UserInfoCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    UserInfoCQ cq = new UserInfoCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            UserInfoCQ cf = new UserInfoCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #27
Source File: BsBoostDocumentRuleCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<BoostDocumentRuleCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<BoostDocumentRuleCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    BoostDocumentRuleCQ cq = new BoostDocumentRuleCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            BoostDocumentRuleCQ cf = new BoostDocumentRuleCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #28
Source File: BsRoleCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<RoleCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<RoleCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    RoleCQ cq = new RoleCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            RoleCQ cf = new RoleCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #29
Source File: BsGroupCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<GroupCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<GroupCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    GroupCQ cq = new GroupCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            GroupCQ cf = new GroupCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #30
Source File: BsFileConfigCQ.java    From fess with Apache License 2.0 6 votes vote down vote up
public void functionScore(OperatorCall<FileConfigCQ> queryLambda,
        ScoreFunctionCall<ScoreFunctionCreator<FileConfigCQ>> functionsLambda,
        final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
    FileConfigCQ cq = new FileConfigCQ();
    queryLambda.callback(cq);
    final Collection<FilterFunctionBuilder> list = new ArrayList<>();
    if (functionsLambda != null) {
        functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
            FileConfigCQ cf = new FileConfigCQ();
            cqLambda.callback(cf);
            list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
        });
    }
    final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}