use of com.yahoo.searchdefinition.document.SDDocumentType 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.document.SDDocumentType in project vespa by vespa-engine.
the class SearchOrdererTestCase method createDocumentReference.
private static void createDocumentReference(Search from, Search to, String refFieldName) {
SDField refField = new TemporarySDField(refFieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(to.getName())));
SDDocumentType fromDocument = from.getDocument();
fromDocument.addField(refField);
Map<String, DocumentReference> originalMap = fromDocument.getDocumentReferences().get().referenceMap();
HashMap<String, DocumentReference> modifiedMap = new HashMap<>(originalMap);
modifiedMap.put(refFieldName, new DocumentReference(refField, to));
fromDocument.setDocumentReferences(new DocumentReferences(modifiedMap));
}
use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class DocumentDeriverTestCase method testDocumentDeriving.
@Test
public void testDocumentDeriving() {
String root = "src/test/derived/documentderiver/";
List<String> files = new ArrayList<>();
files.add(root + "newsarticle.sd");
files.add(root + "newssummary.sd");
files.add(root + "music.sd");
files.add(root + "mail.sd");
files.add(root + "compression_header.sd");
files.add(root + "compression_both.sd");
files.add(root + "compression_body.sd");
File toDir = new File("temp/documentderiver/");
toDir.mkdir();
SearchBuilder builder = Deriver.deriveDocuments(files, toDir.getPath());
try {
assertEqualFiles(root + "documentmanager.cfg", toDir.getPath() + "/documentmanager.cfg");
} catch (IOException e) {
throw new RuntimeException("Exception while comparing files", e);
}
SDDocumentType doc = builder.getSearch("newsarticle").getDocument();
assertNotNull(doc);
}
use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class IndexingScriptRewriterTestCase method processField.
private static ScriptExpression processField(SDField unprocessedField) {
SDDocumentType sdoc = new SDDocumentType("test");
sdoc.addField(unprocessedField);
Search search = new Search("test", null);
search.addDocument(sdoc);
Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
return unprocessedField.getIndexingScript();
}
use of com.yahoo.searchdefinition.document.SDDocumentType 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);
}
Aggregations