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);
}
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());
}
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;
}
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);
}
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);
}
Aggregations