use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ValidateFieldTypesTest method createSingleImportedField.
private static ImportedFields createSingleImportedField(String fieldName, DataType dataType) {
Search targetSearch = new Search("target_doc", MockApplicationPackage.createEmpty());
SDField targetField = new SDField("target_field", dataType);
DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
ImportedField importedField = new ImportedField(fieldName, documentReference, targetField);
return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
use of com.yahoo.searchdefinition.Search 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"));
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SummaryTestCase method reference_fields_can_be_part_of_summary_classes.
@Test
public void reference_fields_can_be_part_of_summary_classes() throws ParseException {
Search adSearch = buildCampaignAdModel();
SummaryClass defaultClass = new SummaryClass(adSearch, adSearch.getSummary("default"), new BaseDeployLogger());
assertEquals(SummaryClassField.Type.LONGSTRING, defaultClass.getField("campaign_ref").getType());
assertEquals(SummaryClassField.Type.LONGSTRING, defaultClass.getField("other_campaign_ref").getType());
SummaryClass myClass = new SummaryClass(adSearch, adSearch.getSummary("my_summary"), new BaseDeployLogger());
assertNull(myClass.getField("campaign_ref"));
assertEquals(SummaryClassField.Type.LONGSTRING, myClass.getField("other_campaign_ref").getType());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ImportedFieldsTestCase method fields_can_be_imported_from_referenced_document_types.
@Test
public void fields_can_be_imported_from_referenced_document_types() throws ParseException {
Search search = buildAdSearch(joinLines("search ad {", " document ad {", " field campaign_ref type reference<campaign> { indexing: attribute }", " field person_ref type reference<person> { indexing: attribute }", " }", " import field campaign_ref.budget as my_budget {}", " import field person_ref.name as my_name {}", "}"));
assertEquals(2, search.importedFields().get().fields().size());
assertSearchContainsImportedField("my_budget", "campaign_ref", "campaign", "budget", search);
assertSearchContainsImportedField("my_name", "person_ref", "person", "name", search);
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class IntegerIndex2AttributeTestCase method testIntegerIndex2Attribute.
@Test
public void testIntegerIndex2Attribute() throws IOException, ParseException {
Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/integerindex2attribute.sd");
search.process();
new IntegerIndex2Attribute(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
SDField f;
f = search.getConcreteField("s1");
assertTrue(f.getAttributes().isEmpty());
assertTrue(f.existsIndex("s1"));
f = search.getConcreteField("s2");
assertEquals(f.getAttributes().size(), 1);
assertTrue(f.existsIndex("s2"));
f = search.getConcreteField("as1");
assertTrue(f.getAttributes().isEmpty());
assertTrue(f.existsIndex("as1"));
f = search.getConcreteField("as2");
assertEquals(f.getAttributes().size(), 1);
assertTrue(f.existsIndex("as2"));
f = search.getConcreteField("i1");
assertEquals(f.getAttributes().size(), 1);
assertTrue(!f.existsIndex("i1"));
f = search.getConcreteField("i2");
assertEquals(f.getAttributes().size(), 1);
assertTrue(!f.existsIndex("i2"));
f = search.getConcreteField("ai1");
assertEquals(search.getConcreteField("ai1").getAttributes().size(), 1);
assertTrue(!search.getConcreteField("ai1").existsIndex("ai1"));
f = search.getConcreteField("ai2");
assertEquals(f.getAttributes().size(), 1);
assertTrue(!f.existsIndex("ai2"));
}
Aggregations