diff options
Diffstat (limited to 'application/src/main/java/com/yahoo/application/Application.java')
-rw-r--r-- | application/src/main/java/com/yahoo/application/Application.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/application/src/main/java/com/yahoo/application/Application.java b/application/src/main/java/com/yahoo/application/Application.java index 1b81897b230..5d8123de48f 100644 --- a/application/src/main/java/com/yahoo/application/Application.java +++ b/application/src/main/java/com/yahoo/application/Application.java @@ -26,6 +26,8 @@ import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.service.ClientProvider; import com.yahoo.jdisc.service.ServerProvider; import com.yahoo.search.Searcher; +import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; +import com.yahoo.search.query.profile.config.QueryProfileXMLReader; import com.yahoo.search.rendering.Renderer; import com.yahoo.text.StringUtilities; import com.yahoo.text.Utf8; @@ -71,6 +73,7 @@ public final class Application implements AutoCloseable { private final List<ContentCluster> contentClusters; private final Path path; private final boolean deletePathWhenClosing; + private final CompiledQueryProfileRegistry compiledQueryProfileRegistry; // For internal use only Application(Path path, Networking networking, boolean deletePathWhenClosing) { @@ -79,6 +82,7 @@ public final class Application implements AutoCloseable { this.deletePathWhenClosing = deletePathWhenClosing; contentClusters = ContentCluster.fromPath(path); container = JDisc.fromPath(path, networking, createVespaModel().configModelRepo()); + compiledQueryProfileRegistry = readQueryProfilesFromApplicationPackage(path); } @Beta @@ -123,6 +127,17 @@ public final class Application implements AutoCloseable { return fromApplicationPackage(file.toPath(), networking); } + private CompiledQueryProfileRegistry readQueryProfilesFromApplicationPackage(Path path) { + String queryProfilePath = path + "/search/query-profiles"; + QueryProfileXMLReader queryProfileXMLReader = new QueryProfileXMLReader(); + + File f = new File(queryProfilePath); + if(f.exists() && f.isDirectory()) { + return queryProfileXMLReader.read(queryProfilePath).compile(); + } + return CompiledQueryProfileRegistry.empty; + } + private VespaModel createVespaModel() { try { List<MlModelImporter> modelImporters = List.of(new VespaImporter(), @@ -149,6 +164,10 @@ public final class Application implements AutoCloseable { return container; } + public CompiledQueryProfileRegistry getCompiledQueryProfileRegistry() { + return compiledQueryProfileRegistry; + } + /** * Shuts down all services. */ |