Search in sources :

Example 21 with Search

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

the class PositionTestCase method requireThatPositionArrayIsSupported.

@Test
public void requireThatPositionArrayIsSupported() throws Exception {
    Search search = SearchBuilder.buildFromFile("src/test/examples/position_array.sd");
    assertNull(search.getAttribute("pos"));
    assertNull(search.getAttribute("pos.x"));
    assertNull(search.getAttribute("pos.y"));
    assertPositionAttribute(search, "pos", Attribute.CollectionType.ARRAY);
    assertPositionSummary(search, "pos", true);
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 22 with Search

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

the class ReferenceFieldTestCase method reference_fields_are_parsed_from_search_definition.

@Test
public void reference_fields_are_parsed_from_search_definition() throws ParseException {
    SearchBuilder builder = new SearchBuilder();
    String campaignSdContent = "search campaign {\n" + "  document campaign {\n" + "  }\n" + "}";
    String salespersonSdContent = "search salesperson {\n" + "  document salesperson {\n" + "  }\n" + "}";
    String adSdContent = "search ad {\n" + "  document ad {\n" + "    field campaign_ref type reference<campaign> { indexing: attribute }\n" + "    field salesperson_ref type reference<salesperson> { indexing: attribute }\n" + "  }\n" + "}";
    builder.importString(campaignSdContent);
    builder.importString(salespersonSdContent);
    builder.importString(adSdContent);
    builder.build();
    Search search = builder.getSearch("ad");
    assertSearchContainsReferenceField("campaign_ref", "campaign", search.getDocument());
    assertSearchContainsReferenceField("salesperson_ref", "salesperson", search.getDocument());
}
Also used : Search(com.yahoo.searchdefinition.Search) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) Test(org.junit.Test)

Example 23 with Search

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

the class TensorTransformTestCase method buildSearch.

private List<Pair<String, String>> buildSearch(String expression) throws ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    QueryProfileRegistry queryProfiles = setupQueryProfileTypes();
    SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfiles);
    builder.importString("search test {\n" + "    document test { \n" + "        field double_field type double { \n" + "            indexing: summary | attribute \n" + "        }\n" + "        field double_array_field type array<double> { \n" + "            indexing: summary | attribute \n" + "        }\n" + "        field weightedset_field type weightedset<double> { \n" + "            indexing: summary | attribute \n" + "        }\n" + "        field tensor_field_1 type tensor(x{}) { \n" + "            indexing: summary | attribute \n" + "            attribute: tensor(x{}) \n" + "        }\n" + "        field tensor_field_2 type tensor(x[3],y[3]) { \n" + "            indexing: summary | attribute \n" + "            attribute: tensor(x[3],y[3]) \n" + "        }\n" + "    }\n" + "    constant file_constant_tensor {\n" + "        file: constants/tensor.json\n" + "        type: tensor(x{})\n" + "    }\n" + "    rank-profile base {\n" + "        constants {\n" + "            base_constant_tensor {\n" + "                value: { {x:0}:0 }\n" + "            }\n" + "        }\n" + "        macro base_tensor() {\n" + "            expression: constant(base_constant_tensor)\n" + "        }\n" + "    }\n" + "    rank-profile test inherits base {\n" + "        constants {\n" + "            test_constant_tensor {\n" + "                value: { {x:0}:1 }\n" + "            }\n" + "        }\n" + "        macro returns_tensor_with_arg(arg1) {\n" + "            expression: 2.0 * arg1\n" + "        }\n" + "        macro wraps_returns_tensor() {\n" + "            expression: returns_tensor\n" + "        }\n" + "        macro returns_tensor() {\n" + "            expression: attribute(tensor_field_2)\n" + "        }\n" + "        macro tensor_inheriting() {\n" + "            expression: base_tensor\n" + "        }\n" + "        macro testexpression() {\n" + "            expression: " + expression + "\n" + "        }\n" + "    }\n" + "}\n");
    builder.build(true, new BaseDeployLogger());
    Search s = builder.getSearch();
    RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(queryProfiles);
    List<Pair<String, String>> testRankProperties = new RawRankProfile(test, queryProfiles, new AttributeFields(s)).configProperties();
    return testRankProperties;
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields) Pair(com.yahoo.collections.Pair)

Example 24 with Search

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

the class ImplicitStructTypesTestCase method testRequireThatImplicitStructsAreUsed.

@Test
public void testRequireThatImplicitStructsAreUsed() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd");
    assertNotNull(search);
    SDDocumentType docType = search.getDocument();
    assertNotNull(docType);
    assertField(docType, "doc_str", DataType.STRING);
    assertField(docType, "doc_str_sum", DataType.STRING);
    assertField(docType, "doc_uri", DataType.URI);
    assertField(docType, "docsum_str", DataType.STRING);
    assertField(docType, "rankfeatures", DataType.STRING);
    assertField(docType, "summaryfeatures", DataType.STRING);
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 25 with Search

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

the class ImplicitStructTypesTestCase method testRequireThatImplicitStructsAreCreated.

@Test
public void testRequireThatImplicitStructsAreCreated() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd");
    assertNotNull(search);
    SDDocumentType docType = search.getDocument();
    assertNotNull(docType);
    assertStruct(docType, PositionDataType.INSTANCE);
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

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