Search in sources :

Example 51 with Search

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

the class RankPropertyVariablesTestCase method testRankPropVariables.

@Test
public void testRankPropVariables() throws IOException, ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    Search search = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd", new BaseDeployLogger(), rankProfileRegistry, new QueryProfileRegistry());
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar1", "foo");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar_2", "bar");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvarOne23", "baz");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar1", "1");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar_4", "4");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$testvarFour23", "234234.234");
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 52 with Search

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

the class ValidateFieldTypesTest method createSearchWithDocument.

private static Search createSearchWithDocument(String documentName) {
    Search search = new Search(documentName, MockApplicationPackage.createEmpty());
    SDDocumentType document = new SDDocumentType(documentName, search);
    search.addDocument(document);
    return search;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search)

Example 53 with Search

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

the class ValidateFieldTypesTest method throws_exception_if_type_of_document_field_does_not_match_summary_field.

@Test
public void throws_exception_if_type_of_document_field_does_not_match_summary_field() {
    Search search = createSearchWithDocument(DOCUMENT_NAME);
    search.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME, DataType.INT));
    search.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, DataType.STRING));
    ValidateFieldTypes validator = new ValidateFieldTypes(search, null, null, null);
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("For search '" + DOCUMENT_NAME + "', field '" + IMPORTED_FIELD_NAME + "': Incompatible types. " + "Expected int for summary field '" + IMPORTED_FIELD_NAME + "', got string.");
    validator.process(true);
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 54 with Search

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

the class SimpleInheritTestCase method testEmptyChild.

@Test
public void testEmptyChild() throws IOException, ParseException {
    String name = "emptychild";
    final String expectedResultsDirName = "src/test/derived/" + name + "/";
    SearchBuilder builder = new SearchBuilder();
    builder.importFile(expectedResultsDirName + "parent.sd");
    builder.importFile(expectedResultsDirName + "child.sd");
    builder.build();
    Search search = builder.getSearch("child");
    String toDirName = "temp/" + name;
    File toDir = new File(toDirName);
    toDir.mkdirs();
    deleteContent(toDir);
    DerivedConfiguration config = new DerivedConfiguration(search, builder.getRankProfileRegistry(), new QueryProfileRegistry());
    config.export(toDirName);
    checkDir(toDirName, expectedResultsDirName);
}
Also used : Search(com.yahoo.searchdefinition.Search) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) File(java.io.File) Test(org.junit.Test)

Example 55 with Search

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

the class AddAttributeTransformToSummaryOfImportedFieldsTest method createSingleImportedField.

private static ImportedFields createSingleImportedField(String fieldName) {
    Search targetSearch = new Search("target_doc", MockApplicationPackage.createEmpty());
    SDField targetField = new SDField("target_field", DataType.INT);
    DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
    ImportedField importedField = new ImportedField(fieldName, documentReference, targetField);
    return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) ImportedField(com.yahoo.searchdefinition.document.ImportedField) SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search) ImportedField(com.yahoo.searchdefinition.document.ImportedField) ImportedFields(com.yahoo.searchdefinition.document.ImportedFields) DocumentReference(com.yahoo.searchdefinition.DocumentReference)

Aggregations

Search (com.yahoo.searchdefinition.Search)62 Test (org.junit.Test)47 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)21 SDField (com.yahoo.searchdefinition.document.SDField)15 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)6 File (java.io.File)5 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)4 RankProfile (com.yahoo.searchdefinition.RankProfile)3 Field (com.yahoo.document.Field)2 StructDataType (com.yahoo.document.StructDataType)2 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)2 DocumentReference (com.yahoo.searchdefinition.DocumentReference)2 Index (com.yahoo.searchdefinition.Index)2 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)2 Attribute (com.yahoo.searchdefinition.document.Attribute)2 ImportedField (com.yahoo.searchdefinition.document.ImportedField)2