use of com.yahoo.searchdefinition.Index in project vespa by vespa-engine.
the class IndexInfo method addUriIndexCommands.
private void addUriIndexCommands(ImmutableSDField field) {
String fieldName = field.getName();
addIndexCommand(fieldName, CMD_FULLURL);
addIndexCommand(fieldName, CMD_LOWERCASE);
addIndexCommand(fieldName + "." + fieldName, CMD_FULLURL);
addIndexCommand(fieldName + "." + fieldName, CMD_LOWERCASE);
addIndexCommand(fieldName + ".path", CMD_FULLURL);
addIndexCommand(fieldName + ".path", CMD_LOWERCASE);
addIndexCommand(fieldName + ".query", CMD_FULLURL);
addIndexCommand(fieldName + ".query", CMD_LOWERCASE);
addIndexCommand(fieldName + ".hostname", CMD_URLHOST);
addIndexCommand(fieldName + ".hostname", CMD_LOWERCASE);
// XXX hack
Index index = field.getIndex("hostname");
if (index != null) {
addIndexCommand(index, CMD_URLHOST);
}
}
use of com.yahoo.searchdefinition.Index in project vespa by vespa-engine.
the class IndexingScriptRewriterTestCase method createPredicateField.
private static SDField createPredicateField(String name, DataType type, String script, int arity, OptionalLong lower_bound, OptionalLong upper_bound) {
SDField field = new SDField(null, name, type);
field.parseIndexingScript(script);
Index index = new Index("foo");
index.setBooleanIndexDefiniton(new BooleanIndexDefinition(OptionalInt.of(arity), lower_bound, upper_bound, OptionalDouble.empty()));
field.addIndex(index);
return field;
}
use of com.yahoo.searchdefinition.Index 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.Index in project vespa by vespa-engine.
the class MakeAliases method process.
@Override
public void process(boolean validate) {
List<String> usedAliases = new ArrayList<>();
for (SDField field : search.allConcreteFields()) {
for (Map.Entry<String, String> e : field.getAliasToName().entrySet()) {
String alias = e.getKey();
String name = e.getValue();
String errMsg = "For search '" + search.getName() + "': alias '" + alias + "' ";
if (validate && search.existsIndex(alias)) {
throw new IllegalArgumentException(errMsg + "is illegal since it is the name of an index.");
}
if (validate && search.getAttribute(alias) != null) {
throw new IllegalArgumentException(errMsg + "is illegal since it is the name of an attribute.");
}
if (validate && usedAliases.contains(alias)) {
throw new IllegalArgumentException(errMsg + "specified more than once.");
}
usedAliases.add(alias);
Index index = field.getIndex(name);
Attribute attribute = field.getAttributes().get(name);
if (index != null) {
// alias will be for index in this case, since it is the one used in a search
index.addAlias(alias);
} else if (attribute != null && !field.doesIndexing()) {
attribute.getAliases().add(alias);
} else {
index = new Index(name);
index.addAlias(alias);
field.addIndex(index);
}
}
}
}
use of com.yahoo.searchdefinition.Index in project vespa by vespa-engine.
the class RankTypeOperation method apply.
public void apply(SDField field) {
if (indexName == null) {
// Set default if the index is not specified.
field.setRankType(type);
} else {
Index index = field.getIndex(indexName);
if (index == null) {
index = new Index(indexName);
field.addIndex(index);
}
index.setRankType(type);
}
}
Aggregations