Search in sources :

Example 1 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles 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)

Example 2 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class SummaryMapTestCase method testPositionDeriving.

@Test
public void testPositionDeriving() throws IOException, ParseException {
    Search search = new Search("store", null);
    SDDocumentType document = new SDDocumentType("store");
    search.addDocument(document);
    String fieldName = "location";
    SDField field = document.addField(fieldName, PositionDataType.INSTANCE);
    field.parseIndexingScript("{ attribute | summary }");
    Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
    SummaryMap summaryMap = new SummaryMap(search, new Summaries(search, new BaseDeployLogger()));
    Iterator transforms = summaryMap.resultTransformIterator();
    FieldResultTransform transform = (FieldResultTransform) transforms.next();
    assertEquals(fieldName, transform.getFieldName());
    assertEquals(SummaryTransform.GEOPOS, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals(PositionDataType.getPositionSummaryFieldName(fieldName), transform.getFieldName());
    assertEquals(SummaryTransform.POSITIONS, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals(PositionDataType.getDistanceSummaryFieldName(fieldName), transform.getFieldName());
    assertEquals(SummaryTransform.DISTANCE, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals("rankfeatures", transform.getFieldName());
    assertEquals(SummaryTransform.RANKFEATURES, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals("summaryfeatures", transform.getFieldName());
    assertEquals(SummaryTransform.SUMMARYFEATURES, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals("location_zcurve", transform.getFieldName());
    assertEquals(SummaryTransform.ATTRIBUTE, transform.getTransform());
    assertTrue(!transforms.hasNext());
    SummarymapConfig.Builder scb = new SummarymapConfig.Builder();
    summaryMap.getConfig(scb);
    SummarymapConfig c = new SummarymapConfig(scb);
    assertEquals(-1, c.defaultoutputclass());
    assertEquals(c.override().size(), 6);
    assertEquals(c.override(0).field(), fieldName);
    assertEquals(c.override(0).command(), "geopos");
    assertEquals(c.override(0).arguments(), PositionDataType.getZCurveFieldName(fieldName));
    assertEquals(c.override(1).field(), PositionDataType.getPositionSummaryFieldName(fieldName));
    assertEquals(c.override(1).command(), "positions");
    assertEquals(c.override(1).arguments(), PositionDataType.getZCurveFieldName(fieldName));
    assertEquals(c.override(2).field(), PositionDataType.getDistanceSummaryFieldName(fieldName));
    assertEquals(c.override(2).command(), "absdist");
    assertEquals(c.override(2).arguments(), PositionDataType.getZCurveFieldName(fieldName));
    assertEquals(c.override(3).field(), "rankfeatures");
    assertEquals(c.override(3).command(), "rankfeatures");
    assertEquals(c.override(3).arguments(), "");
    assertEquals(c.override(4).field(), "summaryfeatures");
    assertEquals(c.override(4).command(), "summaryfeatures");
    assertEquals(c.override(4).arguments(), "");
    assertEquals(c.override(5).field(), "location_zcurve");
    assertEquals(c.override(5).command(), "attribute");
    assertEquals(c.override(5).arguments(), "location_zcurve");
}
Also used : SummarymapConfig(com.yahoo.vespa.config.search.SummarymapConfig) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 3 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class BoldingTestCase method testBoldingNonString.

@Test
public void testBoldingNonString() throws IOException, ParseException {
    try {
        Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/processing/boldnonstring.sd");
        new Bolding(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
        fail();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'bolding: on' for non-text field"));
    }
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Test(org.junit.Test)

Example 4 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class IdTestCase method testExplicitUpperCaseIdField.

@Test
@SuppressWarnings({ "deprecation" })
public void testExplicitUpperCaseIdField() {
    Search search = new Search("test", null);
    SDDocumentType document = new SDDocumentType("test");
    search.addDocument(document);
    SDField uri = new SDField("URI", DataType.URI);
    uri.parseIndexingScript("{ summary | index }");
    document.addField(uri);
    Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
    assertNull(document.getField("uri"));
    assertNull(document.getField("Uri"));
    assertNotNull(document.getField("URI"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Test(org.junit.Test)

Example 5 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class LiteralBoostTestCase method testLiteralBoost.

/**
 * Tests adding of literal boost constructs
 */
@Test
public void testLiteralBoost() {
    Search search = new Search("literalboost", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("literalboost");
    search.addDocument(document);
    SDField field1 = document.addField("a", DataType.STRING);
    field1.parseIndexingScript("{ index }");
    field1.setLiteralBoost(20);
    RankProfile other = new RankProfile("other", search, rankProfileRegistry);
    rankProfileRegistry.addRankProfile(other);
    other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
    Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    // Check attribute fields
    // TODO: assert content
    derived.getAttributeFields();
    // Check il script addition
    assertIndexing(Arrays.asList("clear_state | guard { input a | tokenize normalize stem:\"SHORTEST\" | index a; }", "clear_state | guard { input a | tokenize | index a_literal; }"), search);
    // Check index info addition
    IndexInfo indexInfo = derived.getIndexInfo();
    assertTrue(indexInfo.hasCommand("a", "literal-boost"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Aggregations

QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)20 Test (org.junit.Test)17 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)11 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)10 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)8 Search (com.yahoo.searchdefinition.Search)8 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)6 SDField (com.yahoo.searchdefinition.document.SDField)5 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)4 QueryProfile (com.yahoo.search.query.profile.QueryProfile)3 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)1 RankProfile (com.yahoo.searchdefinition.RankProfile)1 SearchOrderer (com.yahoo.searchdefinition.derived.SearchOrderer)1 MakeAliases (com.yahoo.searchdefinition.processing.MakeAliases)1 SummarymapConfig (com.yahoo.vespa.config.search.SummarymapConfig)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1