1

While submitting http://localhost:8080/search/?query=honda car in vespa application with "honda car" as an unstructured query on automobile database.

I have an external engine which powers query features and ranking features (weights) based on query. I am very well aware of query profiles, but instead of using it if I want to augment query with &feature1="value1"&feature2="value2" how is it possible with searchers or any other component?

We have a method yqlrepresentation() in Query class of Vespa. Is it called for every unstructured query, in other words, does an unstructured query gets converted to YQL and then gets hit on index?

vandit.thakkar
  • 121
  • 1
  • 1
  • 6

1 Answers1

1

To pass features for ranking with the query write a Searcher which adds them to 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);
    }
}

Now you can access these values in ranking expressions using "query(name)".

does an unstructured query gets converted to YQL and then gets hit on index?

YQL is just an external representation language. The query (unstructured or not) is parsed into the object representation under Query.getModel().getQueryTree(). That is what you should work on if you want to modify the query programmatically (from a Searcher).

Jon
  • 2,043
  • 11
  • 9