use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class InheritanceTestCase method testIndexSettingInheritance.
@Test
public void testIndexSettingInheritance() {
SDDocumentType parent = new SDDocumentType("parent");
Search parentSearch = new Search("parent", null);
parentSearch.addDocument(parent);
SDField prefixed = parent.addField("prefixed", DataType.STRING);
prefixed.parseIndexingScript("{ index }");
prefixed.addIndex(new Index("prefixed", true));
SDDocumentType child = new SDDocumentType("child");
child.inherit(parent);
Search childSearch = new Search("child", null);
childSearch.addDocument(child);
prefixed = (SDField) child.getField("prefixed");
assertNotNull(prefixed);
assertEquals(new Index("prefixed", true), childSearch.getIndex("prefixed"));
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class LiteralBoostTestCase method testTwoLiteralBoostFields.
/**
* Tests literal boosts in two fields going to the same index
*/
@Test
public void testTwoLiteralBoostFields() {
Search search = new Search("msb", null);
RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
SDDocumentType document = new SDDocumentType("msb");
search.addDocument(document);
SDField field1 = document.addField("title", DataType.STRING);
field1.parseIndexingScript("{ summary | index }");
field1.setLiteralBoost(20);
SDField field2 = document.addField("body", DataType.STRING);
field2.parseIndexingScript("{ summary | index }");
field2.setLiteralBoost(20);
search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
assertIndexing(Arrays.asList("clear_state | guard { input title | tokenize normalize stem:\"SHORTEST\" | summary title | index title; }", "clear_state | guard { input body | tokenize normalize stem:\"SHORTEST\" | summary body | index body; }", "clear_state | guard { input title | tokenize | index title_literal; }", "clear_state | guard { input body | tokenize | index body_literal; }"), search);
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class LiteralBoostTestCase method testNonDefaultRankLiteralBoost.
/**
* Tests adding a literal boost in a non-default rank profile only
*/
@Test
public void testNonDefaultRankLiteralBoost() {
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 }");
RankProfile other = new RankProfile("other", search, rankProfileRegistry);
rankProfileRegistry.addRankProfile(other);
other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
// 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.SDField in project vespa by vespa-engine.
the class TypeConversionTestCase method testExactStringToStringTypeConversion.
/**
* Tests that exact-string stuff is not spilled over to the default index
*/
@Test
public void testExactStringToStringTypeConversion() {
Search search = new Search("test", null);
RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
SDDocumentType document = new SDDocumentType("test");
search.addDocument(document);
SDField a = new SDField("a", DataType.STRING);
a.parseIndexingScript("{ index }");
document.addField(a);
Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
IndexInfo indexInfo = derived.getIndexInfo();
assertFalse(indexInfo.hasCommand("default", "compact-to-term"));
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class ImplicitSummaries method isValid.
// Returns whether this is valid. Warns if invalid and ignorable. Throws if not ignorable.
private boolean isValid(SummaryField summaryField, Search search, boolean validate) {
if (summaryField.getTransform() == SummaryTransform.DISTANCE || summaryField.getTransform() == SummaryTransform.POSITIONS) {
int sourceCount = summaryField.getSourceCount();
if (validate && sourceCount != 1) {
throw newProcessException(search.getName(), summaryField.getName(), "Expected 1 source field, got " + sourceCount + ".");
}
String sourceName = summaryField.getSingleSource();
if (validate && search.getAttribute(sourceName) == null) {
throw newProcessException(search.getName(), summaryField.getName(), "Summary source attribute '" + sourceName + "' not found.");
}
return true;
}
String fieldName = summaryField.getSourceField();
SDField sourceField = search.getConcreteField(fieldName);
if (validate && sourceField == null) {
throw newProcessException(search, summaryField, "Source field '" + fieldName + "' does not exist.");
}
if (!sourceField.doesSummarying() && !summaryField.getTransform().equals(SummaryTransform.ATTRIBUTE) && !summaryField.getTransform().equals(SummaryTransform.GEOPOS)) {
// Summary transform attribute may indicate that the ilscript was rewritten to remove summary
// by another search that uses this same field in inheritance.
deployLogger.log(Level.WARNING, "Ignoring " + summaryField + ": " + sourceField + " is not creating a summary value in its indexing statement");
return false;
}
if (summaryField.getTransform().isDynamic() && summaryField.getName().equals(sourceField.getName()) && sourceField.doesAttributing()) {
Attribute attribute = sourceField.getAttributes().get(sourceField.getName());
if (attribute != null) {
String destinations = "document summary 'default'";
if (summaryField.getDestinations().size() > 0) {
destinations = "document summaries " + summaryField.getDestinations();
}
deployLogger.log(Level.WARNING, "Will fetch the disk summary value of " + sourceField + " in " + destinations + " since this summary field uses a dynamic summary value (snippet/bolding): Dynamic summaries and bolding " + "is not supported with summary values fetched from in-memory attributes yet. If you want to see partial updates " + "to this attribute, remove any bolding and dynamic snippeting from this field");
// Note: The dynamic setting has already overridden the attribute map setting,
// so we do not need to actually do attribute.setSummary(false) here
// Also, we can not do this, since it makes it impossible to fetch this attribute
// in another summary
}
}
return true;
}
Aggregations