/** Returns a deep copy of this item */ public CompositeItem clone() { CompositeItem copy = (CompositeItem) super.clone(); copy.subitems = new java.util.ArrayList<>(); for (Item subItem : subitems) { Item subItemCopy = subItem.clone(); copy.adding(subItemCopy); copy.subitems.add(subItemCopy); } fixConnexity(copy); return copy; }
@Override public Result search(Query query, Execution execution) { QueryTree tree = query.getModel().getQueryTree(); Item root = tree.getRoot(); if (root != null) { Item newRoot = root.clone(); newRoot = simplifyPhrases(newRoot); // Sets new root instead of transforming the query tree // to make code nicer if the root is a single term phrase if (!root.equals(newRoot)) { tree.setRoot(newRoot); query.trace("Collapsing single term phrases to single terms", true, 2); } } return execution.search(query); }