private void addSources(List<PageElement> pages, Query query) {
        // Determine all wanted sources
        Set<Source> pageSources = new HashSet<>();
        for (PageElement page : pages)
            pageSources.addAll(((PageTemplate)page).getSources());

        addErrorIfSameSourceMultipleTimes(pages,pageSources,query);

        if (!query.getModel().getSources().isEmpty()) {
            // Add properties if the source list is set explicitly, but do not modify otherwise
            addParametersForIncludedSources(pageSources, query);
            return;
        }

        if (pageSources.contains(Source.any)) {
            IntentModel intentModel = IntentModel.getFrom(query);
            if (intentModel != null) {
                query.getModel().getSources().addAll(intentModel.getSourceNames());
                addPageTemplateSources(pageSources, query);
            }
            // otherwise leave empty to search all
        }
        else { // Let the page templates decide
            addPageTemplateSources(pageSources, query);
        }
    }
Sets query.getModel().getSources() to the right value and add source parameters specified in templates
container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java