/**
* Execute the query
*
* Removes any duplicates that may be present (ID search can cause duplicates -
* it is better to remove them here)
*
* @param sp SearchParameters describing the search to execute.
* @param exceptionOnError True to throw a runtime exception on error, false to return empty resultset
*
* @return Array of Node objects
*/
protected Object[] query(SearchParameters sp, boolean exceptionOnError){
Collection<ScriptNode> set = null;
// perform the search against the repo
ResultSet results = null;
try
{
results = this.services.getSearchService().query(sp);
if (results.length() != 0)
{
set = new LinkedHashSet<ScriptNode>(results.length(), 1.0f);
for (ResultSetRow row: results)
{
NodeRef nodeRef = row.getNodeRef();
String [] fragments = row.getFragments();
ScriptNode node = new ScriptNode(nodeRef, this.services, getScope());
node.setFragments(fragments);
set.add(node);