Search in sources :

Example 1 with SimpleIndexedItem

use of com.yahoo.prelude.query.SimpleIndexedItem in project vespa by vespa-engine.

the class QueryRewrite method rewriteSddocname.

private static Item rewriteSddocname(Item item) {
    if (item instanceof CompositeItem) {
        CompositeItem parent = (CompositeItem) item;
        for (int i = 0, len = parent.getItemCount(); i < len; ++i) {
            Item oldChild = parent.getItem(i);
            Item newChild = rewriteSddocname(oldChild);
            if (oldChild != newChild) {
                parent.setItem(i, newChild);
            }
        }
    } else if (item instanceof SimpleIndexedItem) {
        SimpleIndexedItem oldItem = (SimpleIndexedItem) item;
        if (Hit.SDDOCNAME_FIELD.equals(oldItem.getIndexName())) {
            SubstringItem newItem = new SubstringItem(oldItem.getIndexedString());
            newItem.setIndexName("[documentmetastore]");
            return newItem;
        }
    }
    return item;
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) NullItem(com.yahoo.prelude.query.NullItem) SimpleIndexedItem(com.yahoo.prelude.query.SimpleIndexedItem) OrItem(com.yahoo.prelude.query.OrItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) Item(com.yahoo.prelude.query.Item) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) NotItem(com.yahoo.prelude.query.NotItem) NearItem(com.yahoo.prelude.query.NearItem) EquivItem(com.yahoo.prelude.query.EquivItem) CompositeItem(com.yahoo.prelude.query.CompositeItem) SimpleIndexedItem(com.yahoo.prelude.query.SimpleIndexedItem) SubstringItem(com.yahoo.prelude.query.SubstringItem)

Example 2 with SimpleIndexedItem

use of com.yahoo.prelude.query.SimpleIndexedItem in project vespa by vespa-engine.

the class QueryRewrite method rewriteSddocname.

/**
 * Replaces and {@link SimpleIndexedItem} searching in the {@link Hit#SDDOCNAME_FIELD} with an item
 * appropriate for the search node.
 */
public static void rewriteSddocname(Query query) {
    Item oldRoot = query.getModel().getQueryTree().getRoot();
    Item newRoot = rewriteSddocname(oldRoot);
    if (oldRoot != newRoot) {
        query.getModel().getQueryTree().setRoot(newRoot);
    }
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) NullItem(com.yahoo.prelude.query.NullItem) SimpleIndexedItem(com.yahoo.prelude.query.SimpleIndexedItem) OrItem(com.yahoo.prelude.query.OrItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) Item(com.yahoo.prelude.query.Item) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) NotItem(com.yahoo.prelude.query.NotItem) NearItem(com.yahoo.prelude.query.NearItem) EquivItem(com.yahoo.prelude.query.EquivItem)

Aggregations

AndItem (com.yahoo.prelude.query.AndItem)2 CompositeItem (com.yahoo.prelude.query.CompositeItem)2 EquivItem (com.yahoo.prelude.query.EquivItem)2 Item (com.yahoo.prelude.query.Item)2 NearItem (com.yahoo.prelude.query.NearItem)2 NotItem (com.yahoo.prelude.query.NotItem)2 NullItem (com.yahoo.prelude.query.NullItem)2 OrItem (com.yahoo.prelude.query.OrItem)2 RankItem (com.yahoo.prelude.query.RankItem)2 SimpleIndexedItem (com.yahoo.prelude.query.SimpleIndexedItem)2 SubstringItem (com.yahoo.prelude.query.SubstringItem)2