From 87f8118108034ccf1aec9c58e5daedd13c0a423e Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 16 Jul 2014 16:04:19 +0200 Subject: [PATCH] added option to delete documents from the webgraph --- htroot/IndexDeletion_p.html | 8 ++++++++ htroot/IndexDeletion_p.java | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/htroot/IndexDeletion_p.html b/htroot/IndexDeletion_p.html index 1b9ec9000..1fee30ad6 100644 --- a/htroot/IndexDeletion_p.html +++ b/htroot/IndexDeletion_p.html @@ -108,6 +108,14 @@ Delete by Solr Query

This is the most generic option: select a set of documents using a solr query.

+
Core
+
+ +
q=
diff --git a/htroot/IndexDeletion_p.java b/htroot/IndexDeletion_p.java index 6afb16118..748633dc5 100644 --- a/htroot/IndexDeletion_p.java +++ b/htroot/IndexDeletion_p.java @@ -55,6 +55,9 @@ public class IndexDeletion_p { SolrConnector webgraphConnector = sb.index.fulltext().getWebgraphConnector(); if (post == null || post.size() == 0) defaultConnector.commit(false); // we must do a commit here because the user cannot see a proper count. + String schemaName = CollectionSchema.CORE_NAME; + if (post != null) schemaName = post.get("core", schemaName); + // Delete by URL Matching String urldelete = post == null ? "" : post.get("urldelete", ""); boolean urldelete_mm_subpath_checked = post == null ? true : post.get("urldelete-mm", "subpath").equals("subpath"); @@ -225,18 +228,20 @@ public class IndexDeletion_p { if (post != null && (post.containsKey("simulate-querydelete") || post.containsKey("engage-querydelete"))) { boolean simulate = post.containsKey("simulate-querydelete"); + + SolrConnector connector = schemaName.equals(CollectionSchema.CORE_NAME) ? defaultConnector : sb.index.fulltext().getWebgraphConnector(); if (simulate) { try { - count = (int) defaultConnector.getCountByQuery(querydelete); + count = (int) connector.getCountByQuery(querydelete); } catch (final IOException e) { } prop.put("querydelete-active", count == 0 ? 2 : 1); } else { try { - ConcurrentLog.info("IndexDeletion", "delete by query \"" + querydelete + "\", size before deletion = " + defaultConnector.getSize()); - defaultConnector.deleteByQuery(querydelete); - defaultConnector.commit(false); - ConcurrentLog.info("IndexDeletion", "delete by query \"" + querydelete + "\", size after commit = " + defaultConnector.getSize()); + ConcurrentLog.info("IndexDeletion", "delete by query \"" + querydelete + "\", size before deletion = " + connector.getSize()); + connector.deleteByQuery(querydelete); + connector.commit(false); + ConcurrentLog.info("IndexDeletion", "delete by query \"" + querydelete + "\", size after commit = " + connector.getSize()); sb.tables.recordAPICall(post, "IndexDeletion_p.html", WorkTables.TABLE_API_TYPE_DELETION, "deletion, solr query, q = " + querydelete); } catch (final IOException e) { } @@ -246,6 +251,13 @@ public class IndexDeletion_p { } prop.put("doccount", defaultConnector.getSize()); + + prop.put("cores_" + 0 + "_name", CollectionSchema.CORE_NAME); + prop.put("cores_" + 0 + "_selected", CollectionSchema.CORE_NAME.equals(schemaName) ? 1 : 0); + prop.put("cores_" + 1 + "_name", WebgraphSchema.CORE_NAME); + prop.put("cores_" + 1 + "_selected", WebgraphSchema.CORE_NAME.equals(schemaName) ? 1 : 0); + prop.put("cores", 2); + // return rewrite properties return prop; }