Search in sources :

Example 1 with ParseException

use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.

the class SearchBuilder method createFromDirectory.

public static SearchBuilder createFromDirectory(String dir, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException {
    SearchBuilder builder = new SearchBuilder(MockApplicationPackage.fromSearchDefinitionDirectory(dir), rankProfileRegistry, queryProfileRegistry);
    for (Iterator<Path> i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) {
        builder.importFile(i.next());
    }
    builder.build(true, new BaseDeployLogger());
    return builder;
}
Also used : Path(java.nio.file.Path) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) DocumentModel(com.yahoo.vespa.documentmodel.DocumentModel) SDParser(com.yahoo.searchdefinition.parser.SDParser) IOUtils(com.yahoo.io.IOUtils) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) DeployLogger(com.yahoo.config.application.api.DeployLogger) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ArrayList(java.util.ArrayList) SearchOrderer(com.yahoo.searchdefinition.derived.SearchOrderer) Processing(com.yahoo.searchdefinition.processing.Processing) TokenMgrError(com.yahoo.searchdefinition.parser.TokenMgrError) LinkedList(java.util.LinkedList) Path(java.nio.file.Path) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) Exceptions(com.yahoo.yolean.Exceptions) SimpleCharStream(com.yahoo.searchdefinition.parser.SimpleCharStream) Iterator(java.util.Iterator) Files(java.nio.file.Files) IOException(java.io.IOException) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) File(java.io.File) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) List(java.util.List) NamedReader(com.yahoo.io.reader.NamedReader) ParseException(com.yahoo.searchdefinition.parser.ParseException) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) File(java.io.File)

Example 2 with ParseException

use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.

the class SearchBuilder method importString.

private String importString(String str, String searchDefDir, DeployLogger deployLogger) throws ParseException {
    Search search;
    SimpleCharStream stream = new SimpleCharStream(str);
    try {
        search = new SDParser(stream, deployLogger, app, rankProfileRegistry).search(docTypeMgr, searchDefDir);
    } catch (TokenMgrError e) {
        throw new ParseException("Unknown symbol: " + e.getMessage());
    } catch (ParseException pe) {
        throw new ParseException(stream.formatException(Exceptions.toMessageString(pe)));
    }
    return importRawSearch(search);
}
Also used : SimpleCharStream(com.yahoo.searchdefinition.parser.SimpleCharStream) SDParser(com.yahoo.searchdefinition.parser.SDParser) TokenMgrError(com.yahoo.searchdefinition.parser.TokenMgrError) ParseException(com.yahoo.searchdefinition.parser.ParseException)

Example 3 with ParseException

use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.

the class MockApplicationPackage method getSearchDefinitions.

@Override
public List<NamedReader> getSearchDefinitions() {
    ArrayList<NamedReader> readers = new ArrayList<>();
    SearchBuilder searchBuilder = new SearchBuilder(this, new RankProfileRegistry(), queryProfileRegistry);
    for (String sd : searchDefinitions) {
        try {
            String name = searchBuilder.importString(sd);
            readers.add(new NamedReader(name + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd)));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
    return readers;
}
Also used : StringReader(java.io.StringReader) NamedReader(com.yahoo.io.reader.NamedReader) ParseException(com.yahoo.searchdefinition.parser.ParseException)

Example 4 with ParseException

use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.

the class Deriver method getUnprocessingSearchBuilder.

public static SearchBuilder getUnprocessingSearchBuilder(List<String> sds) {
    SearchBuilder builder = new UnprocessingSearchBuilder();
    try {
        for (String s : sds) {
            builder.importFile(s);
        }
    } catch (ParseException | IOException e) {
        throw new IllegalArgumentException(e);
    }
    builder.build();
    return builder;
}
Also used : UnprocessingSearchBuilder(com.yahoo.searchdefinition.UnprocessingSearchBuilder) UnprocessingSearchBuilder(com.yahoo.searchdefinition.UnprocessingSearchBuilder) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) ParseException(com.yahoo.searchdefinition.parser.ParseException) IOException(java.io.IOException)

Example 5 with ParseException

use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.

the class Deriver method getSearchBuilder.

public static SearchBuilder getSearchBuilder(List<String> sds) {
    SearchBuilder builder = new SearchBuilder();
    try {
        for (String s : sds) {
            builder.importFile(s);
        }
    } catch (ParseException | IOException e) {
        throw new IllegalArgumentException(e);
    }
    builder.build();
    return builder;
}
Also used : UnprocessingSearchBuilder(com.yahoo.searchdefinition.UnprocessingSearchBuilder) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) ParseException(com.yahoo.searchdefinition.parser.ParseException) IOException(java.io.IOException)

Aggregations

ParseException (com.yahoo.searchdefinition.parser.ParseException)7 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)3 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)3 IOException (java.io.IOException)3 NamedReader (com.yahoo.io.reader.NamedReader)2 SDParser (com.yahoo.searchdefinition.parser.SDParser)2 SimpleCharStream (com.yahoo.searchdefinition.parser.SimpleCharStream)2 TokenMgrError (com.yahoo.searchdefinition.parser.TokenMgrError)2 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)1 DeployLogger (com.yahoo.config.application.api.DeployLogger)1 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)1 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)1 IOUtils (com.yahoo.io.IOUtils)1 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)1 Search (com.yahoo.searchdefinition.Search)1 SearchOrderer (com.yahoo.searchdefinition.derived.SearchOrderer)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 Processing (com.yahoo.searchdefinition.processing.Processing)1 DocumentModel (com.yahoo.vespa.documentmodel.DocumentModel)1