Search in sources :

Example 1 with SearchOrderer

use of com.yahoo.searchdefinition.derived.SearchOrderer in project vespa by vespa-engine.

the class SearchBuilder method build.

/**
 * Processes and finalizes the imported search definitions so that they become available through the {@link
 * #getSearch(String)} method.
 *
 * @throws IllegalStateException Thrown if this method has already been called.
 * @param deployLogger The logger to use during build
 */
public void build(boolean validate, DeployLogger deployLogger) {
    if (isBuilt)
        throw new IllegalStateException("Model already built");
    List<Search> built = new ArrayList<>();
    List<SDDocumentType> sdocs = new ArrayList<>();
    sdocs.add(SDDocumentType.VESPA_DOCUMENT);
    for (Search search : searchList) {
        if (search.hasDocument()) {
            sdocs.add(search.getDocument());
        }
    }
    SDDocumentTypeOrderer orderer = new SDDocumentTypeOrderer(sdocs, deployLogger);
    orderer.process();
    for (SDDocumentType sdoc : orderer.getOrdered()) {
        new FieldOperationApplierForStructs().process(sdoc);
        new FieldOperationApplier().process(sdoc);
    }
    DocumentReferenceResolver resolver = new DocumentReferenceResolver(searchList);
    sdocs.forEach(resolver::resolveReferences);
    if (validate)
        new DocumentGraphValidator().validateDocumentGraph(sdocs);
    DocumentModelBuilder builder = new DocumentModelBuilder(model);
    for (Search search : new SearchOrderer().order(searchList)) {
        new FieldOperationApplierForSearch().process(search);
        // These two needed for a couple of old unit tests, ideally these are just read from app
        process(search, deployLogger, new QueryProfiles(queryProfileRegistry), validate);
        built.add(search);
    }
    builder.addToModel(searchList);
    if (validate && !builder.valid())
        throw new IllegalArgumentException("Impossible to build a correct model.");
    searchList = built;
    isBuilt = true;
}
Also used : ArrayList(java.util.ArrayList) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) SearchOrderer(com.yahoo.searchdefinition.derived.SearchOrderer) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles)

Aggregations

SearchOrderer (com.yahoo.searchdefinition.derived.SearchOrderer)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)1 ArrayList (java.util.ArrayList)1