} else {
int opHash = query.get(0).hashCode();
int numArgs = query.size();
switch(opHash) {
case DbServiceUtil.OP_HASH_AS:
queryNode = index.getRange(new Range(prefix, null, null, true, true), revNum);
if (query.size() > 2) {
throw new RuntimeException("Not yet supported");
// QueryNodeTemplate subNode=applyQueryToBagIndex(prefix, (List)query.get(2), index, revNum);
// vars.put((String)query.get(1), ExternalTermQueryNode.make(subNode.queryNode, queryNode));
// queryNode = subNode.queryNode;
// vars = subNode.varMappings;
} else {
vars.put((String)query.get(1), queryNode);
}
break;
case DbServiceUtil.OP_HASH_OR:
case DbServiceUtil.OP_HASH_AND:
Object subQueryObject = query.get(1);
if (!(subQueryObject instanceof List)) {
throw new ApiException("QueryFormatError", "\""+query.get(0)+"\" operator must have a list in the first position, instead found: "+subQueryObject);
}
List<Object> subQueries = (List<Object>)query.get(1);
int numQueries = subQueries.size();
clauses = new ArrayList<QueryNode>(numQueries);
for(int i=0; i<numQueries; i++) {
QueryNodeTemplate node=applyPatternToBagIndex(prefix, subQueries.get(i), index, revNum);
if (node.queryNode != null) clauses.add(node.queryNode);
vars.putAll(node.varMappings);
}
if (opHash == DbServiceUtil.OP_HASH_OR) {
queryNode = OrderedOrQueryNode.make(clauses);
} else {
queryNode = AndQueryNode.make(clauses);
}
break;
case DbServiceUtil.OP_HASH_NOT:
QueryNode matchesSoFar = index.getRange(new Range(prefix, null, null, true, true), revNum);
clauses = new ArrayList<QueryNode>(numArgs-1);
for(int i=1; i<numArgs; i++) {
QueryNodeTemplate node=applyPatternToBagIndex(prefix, query.get(i), index, revNum);
if (node.queryNode != null) clauses.add(node.queryNode);
}