Search in sources :

Example 6 with Index

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);
    }
}
Also used : Index(com.yahoo.searchdefinition.Index)

Example 7 with Index

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;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Index(com.yahoo.searchdefinition.Index) BooleanIndexDefinition(com.yahoo.searchdefinition.document.BooleanIndexDefinition)

Example 8 with Index

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"));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Index(com.yahoo.searchdefinition.Index) Test(org.junit.Test)

Example 9 with Index

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);
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Attribute(com.yahoo.searchdefinition.document.Attribute) ArrayList(java.util.ArrayList) Index(com.yahoo.searchdefinition.Index) Map(java.util.Map)

Example 10 with 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);
    }
}
Also used : Index(com.yahoo.searchdefinition.Index)

Aggregations

Index (com.yahoo.searchdefinition.Index)12 SDField (com.yahoo.searchdefinition.document.SDField)7 Search (com.yahoo.searchdefinition.Search)2 Attribute (com.yahoo.searchdefinition.document.Attribute)2 BooleanIndexDefinition (com.yahoo.searchdefinition.document.BooleanIndexDefinition)2 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)2 Map (java.util.Map)2 DerivedConfiguration (com.yahoo.searchdefinition.derived.DerivedConfiguration)1 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 DocumentSummary (com.yahoo.vespa.documentmodel.DocumentSummary)1 AbstractSearchCluster (com.yahoo.vespa.model.search.AbstractSearchCluster)1 DocumentDatabase (com.yahoo.vespa.model.search.DocumentDatabase)1 IndexedSearchCluster (com.yahoo.vespa.model.search.IndexedSearchCluster)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Test (org.junit.Test)1