扩展查询具有外部驱动的排名和查询功能?

时间:2018-03-15 07:16:50

标签: vespa

使用" honda car"在vespa应用程序中提交Exception in thread "main" java.lang.IllegalStateException: Score corruption: the workingScore (-17hard/0medium/0soft) is not the uncorruptedScore (-20hard/0medium/0soft) after completedAction ([TaskAssignment-5 {Machine-1([023]) -> Machine-1([023])}, TaskAssignment-5 {TimeGrain-2 -> TimeGrain-2}]): The corrupted scoreDirector has no ConstraintMatch(s) which are in excess. The corrupted scoreDirector has 1 ConstraintMatch(s) which are missing: com.esquel.configuration/Make sure interval large than preparation time/[TaskAssignment-4]=-3hard/0medium/0soft Check your score constraints. at org.optaplanner.core.impl.score.director.AbstractScoreDirector.assertWorkingScoreFromScratch(AbstractScoreDirector.java:496) at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.assertWorkingScoreFromScratch(DefaultSolverScope.java:132) at org.optaplanner.core.impl.phase.scope.AbstractPhaseScope.assertWorkingScoreFromScratch(AbstractPhaseScope.java:167) at org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider.processMove(ConstructionHeuristicDecider.java:140) at org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider.doMove(ConstructionHeuristicDecider.java:126) at org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider.decideNextStep(ConstructionHeuristicDecider.java:99) at org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase.solve(DefaultConstructionHeuristicPhase.java:74) at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:87) at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:167) at com.esquel.main.App.startPlan(App.java:94) at com.esquel.main.App.main(App.java:43) 作为汽车数据库的非结构化查询。

我有一个外部引擎,可以根据查询为查询功能和排名功能(权重)提供支持。我非常了解查询配置文件,但如果我想用& feature1 =" value1"& feature2 =" value2"来增强查询,请使用它。如何与搜索者或任何其他组件一起使用?

我们在Vespa的Query类中有一个方法http://localhost:8080/search/?query=honda car。它是否为每个非结构化查询调用,换句话说,非结构化查询是否转换为YQL然后被索引命中?

1 个答案:

答案 0 :(得分:1)

要通过查询传递排名功能,请编写一个Searcher,将其添加到Query.getRanking()。getFeatures():

public class FeatureAdder extends Searcher {
    @Override
    public Result search(Query query, Execution execution) {
        Map<String, Double> features = lookUpFeaturesFromExternalStore();
        features.forEach((name, value) -> query.getRanking().getFeatures().put("query(" + name + ")", 
                                                                               String.valueOf(value)));
        return execution.search(query);
    }
}

现在,您可以使用“query(name)”在排名表达式中访问这些值。

  

非结构化查询是否会转换为YQL,然后会被索引命中?

YQL只是一种外部表示语言。查询(非结构化或非结构化)被解析为Query.getModel()。getQueryTree()下的对象表示。如果您想以编程方式(从搜索者)修改查询,那么您应该处理这个问题。