Search in sources :

Example 1 with DerivedConfiguration

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

the class IndexedSearchCluster method deriveAllSearchDefinitions.

protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches, List<com.yahoo.searchdefinition.Search> globalSearches) {
    for (SearchDefinitionSpec spec : localSearches) {
        com.yahoo.searchdefinition.Search search = spec.getSearchDefinition().getSearch();
        if (!(search instanceof UnproperSearch)) {
            DocumentDatabase db = new DocumentDatabase(this, search.getName(), new DerivedConfiguration(search, globalSearches, deployLogger(), getRoot().getDeployState().rankProfileRegistry(), getRoot().getDeployState().getQueryProfiles().getRegistry()));
            // TODO: remove explicit adding of user configs when the complete content model is built using builders.
            db.mergeUserConfigs(spec.getUserConfigs());
            documentDbs.add(db);
        }
    }
}
Also used : DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) UnproperSearch(com.yahoo.searchdefinition.UnproperSearch)

Example 2 with DerivedConfiguration

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

the class RankingExpressionValidationTestCase method assertFailsExpression.

private void assertFailsExpression(String expression) throws ParseException {
    try {
        RankProfileRegistry registry = new RankProfileRegistry();
        Search search = importWithExpression(expression, registry);
        // cause rank profile parsing
        new DerivedConfiguration(search, registry, new QueryProfileRegistry());
        fail("No exception on incorrect ranking expression " + expression);
    } catch (IllegalArgumentException e) {
        // Success
        // TODO: Where's the "com.yahoo.searchdefinition.parser.ParseException:"  nonsense coming from?
        assertTrue("Got unexpected error message: " + e.getCause().getMessage(), e.getCause().getMessage().startsWith("com.yahoo.searchdefinition.parser.ParseException: Could not parse ranking expression '" + expression + "'"));
    }
}
Also used : DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 3 with DerivedConfiguration

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

the class RankingExpressionsTestCase method testThatIncludingFileInSubdirFails.

@Test(expected = IllegalArgumentException.class)
public void testThatIncludingFileInSubdirFails() throws IOException, ParseException {
    RankProfileRegistry registry = new RankProfileRegistry();
    Search search = SearchBuilder.createFromDirectory("src/test/examples/rankingexpressioninfile", registry, new QueryProfileRegistry()).getSearch();
    // rank profile parsing happens during deriving
    new DerivedConfiguration(search, registry, new QueryProfileRegistry());
}
Also used : DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 4 with DerivedConfiguration

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

the class IncorrectRankingExpressionFileRefTestCase method testIncorrectRef.

@Test
public void testIncorrectRef() throws IOException, ParseException {
    try {
        RankProfileRegistry registry = new RankProfileRegistry();
        Search search = SearchBuilder.buildFromFile("src/test/examples/incorrectrankingexpressionfileref.sd", registry, new QueryProfileRegistry());
        // cause rank profile parsing
        new DerivedConfiguration(search, registry, new QueryProfileRegistry());
        fail("parsing should have failed");
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        assertTrue(e.getCause().getMessage().contains("Could not read ranking expression file"));
        assertTrue(e.getCause().getMessage().contains("wrongending.expr.expression"));
    }
}
Also used : DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 5 with DerivedConfiguration

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

the class NoPrefixForIndexes method validate.

@Override
public void validate(VespaModel model, DeployState deployState) {
    for (AbstractSearchCluster cluster : model.getSearchClusters()) {
        if (cluster instanceof IndexedSearchCluster) {
            IndexedSearchCluster sc = (IndexedSearchCluster) cluster;
            for (DocumentDatabase docDb : sc.getDocumentDbs()) {
                DerivedConfiguration sdConfig = docDb.getDerivedConfiguration();
                Search search = sdConfig.getSearch();
                for (SDField field : search.allConcreteFields()) {
                    if (field.doesIndexing()) {
                        // if (!field.getIndexTo().isEmpty() && !field.getIndexTo().contains(field.getName())) continue;
                        if (field.getMatching().getAlgorithm().equals(Matching.Algorithm.PREFIX)) {
                            failField(search, field);
                        }
                        for (Map.Entry<String, Index> e : field.getIndices().entrySet()) {
                            if (e.getValue().isPrefix()) {
                                failField(search, field);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : IndexedSearchCluster(com.yahoo.vespa.model.search.IndexedSearchCluster) DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) SDField(com.yahoo.searchdefinition.document.SDField) AbstractSearchCluster(com.yahoo.vespa.model.search.AbstractSearchCluster) Search(com.yahoo.searchdefinition.Search) Index(com.yahoo.searchdefinition.Index) DocumentDatabase(com.yahoo.vespa.model.search.DocumentDatabase) Map(java.util.Map)

Aggregations

DerivedConfiguration (com.yahoo.searchdefinition.derived.DerivedConfiguration)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)4 Test (org.junit.Test)3 Index (com.yahoo.searchdefinition.Index)1 Search (com.yahoo.searchdefinition.Search)1 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)1 UnproperSearch (com.yahoo.searchdefinition.UnproperSearch)1 SDField (com.yahoo.searchdefinition.document.SDField)1 AbstractSearchCluster (com.yahoo.vespa.model.search.AbstractSearchCluster)1 DocumentDatabase (com.yahoo.vespa.model.search.DocumentDatabase)1 IndexedSearchCluster (com.yahoo.vespa.model.search.IndexedSearchCluster)1 Map (java.util.Map)1