protected NotItem addNot(Item item,NotItem not) { if (not==null) not=new NotItem(); not.addNegativeItem(item); return not; }
@NonNull private CompositeItem buildNotAnd(String key, Inspector value) { NotItem notItem = new NotItem(); addItemsFromInspector(notItem, value); return notItem; }
private CompositeItem createType(TermType termType) { if (termType==TermType.DEFAULT) { if (query.getModel().getType().equals(Query.Type.ANY)) return new OrItem(); else return new AndItem(); } else if (termType==TermType.AND) { return new AndItem(); } else if (termType==TermType.OR) { return new OrItem(); } else if (termType==TermType.RANK) { return new RankItem(); } else if (termType==TermType.NOT) { return new NotItem(); } throw new IllegalArgumentException("Programing error, this method should be updated with add in RankType"); }
@NonNull private CompositeItem buildAnd(OperatorNode<ExpressionOperator> ast) { AndItem andItem = new AndItem(); NotItem notItem = new NotItem(); convertVarArgsAnd(ast, 0, andItem, notItem); Preconditions .checkArgument(andItem.getItemCount() > 0, "Vespa does not support AND with no logically positive branches."); if (notItem.getItemCount() == 0) { return andItem; } if (andItem.getItemCount() == 1) { notItem.setPositiveItem(andItem.getItem(0)); } else { notItem.setPositiveItem(andItem); } return notItem; }
public Result search(Query query, Execution execution) { // Get tensor and read items from user profile Object userIdProperty = query.properties().get("user_id"); if (userIdProperty != null) { Hit userProfile = retrieveUserProfile(userIdProperty.toString(), execution); if (userProfile != null) { addUserProfileTensorToQuery(query, userProfile); NotItem notItem = new NotItem(); notItem.addItem(new IntItem(1, "has_user_item_cf")); for (String item : getReadItems(userProfile.getField("has_read_items"))){ notItem.addItem(new WordItem(item, "post_id")); } QueryTreeUtil.andQueryItemWithRoot(query, notItem); } } // Restrict to search in blog_posts query.getModel().setRestrict("blog_post"); // Rank blog posts using tensor rank profile if(query.properties().get("ranking") == null) { query.properties().set(new CompoundName("ranking"), "tensor"); } return execution.search(query); }
} else if (isTheWord("andnot", item)) { if (topLevelIsClosed || !(topLevelItem instanceof NotItem)) { NotItem not = new NotItem();