Field Re-Indexing: display list of fields in reindex queue

change servlet to display statistic on 1st click (instead after refresh)
pull/1/head
reger 11 years ago
parent 7f501b7c38
commit 02fe8b43ba

@ -11,12 +11,13 @@
<h2>Field Re-Indexing</h2>
<p>In case that an index schema has changed, all documents with missing field entries can be indexed again with a reindex job.</p>
<form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<table><tr valign="top"><td>
<fieldset>
<table>
<tr>
<td>Documents in current queue</td>
<td>#[querysize]#</td>
<td>#(showstartbutton)#<input type="submit" value="refresh page"/>::#(/showstartbutton)#</td>
<td>#(reindexjobrunning)#::<input type="submit" value="refresh page"/>#(/reindexjobrunning)#</td>
</tr>
<tr>
<td>Documents processed</td>
@ -34,12 +35,20 @@
<td></td>
</tr>
</table>
#(showstartbutton)#
<input type="submit" name="stopreindex" value="stop reindexing"/>
::<input type="submit" name="reindexnow" value="start reindex job now"/>
#(/showstartbutton)#
#(reindexjobrunning)#
<input type="submit" name="reindexnow" value="start reindex job now"/>
::<input type="submit" name="stopreindex" value="stop reindexing"/>
#(/reindexjobrunning)#
<p class="info">#[infomessage]#</p>
</fieldset>
</td><td>
#(reindexjobrunning)#::
<fieldset><legend>Remaining field list</legend>
<p>reindex documents containing these fields: </p>
<p>#[fieldlist]#</p>
</fieldset>
#(/reindexjobrunning)#
</td></tr></table>
</form>
#%env/templates/footer.template%#
</body>

@ -36,34 +36,49 @@ public class IndexReIndexMonitor_p {
prop.put("docsprocessed", "0");
prop.put("currentselectquery","");
BusyThread bt = sb.getThread("reindexSolr");
if (bt == null) {
if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) {
migration.reindexToschema(sb);
prop.put("querysize", "0");
prop.put("infomessage","reindex job started");
bt = sb.getThread("reindexSolr"); //get new created job for following posts
}
}
if (bt != null) {
prop.put("reindexjobrunning", 1);
prop.put("querysize", bt.getJobCount());
if (bt instanceof ReindexSolrBusyThread) {
prop.put("docsprocessed", ((ReindexSolrBusyThread) bt).getProcessed());
prop.put("currentselectquery","q="+((ReindexSolrBusyThread) bt).getCurrentQuery());
// prepare list of fields in queue
final String[] querylist = ((ReindexSolrBusyThread) bt).getQueryList();
if (querylist != null) {
String allfieldnames = "";
for (String oneqs : querylist) { // just use fieldname from query (fieldname:[* TO *])
allfieldnames = allfieldnames + oneqs.substring(0, oneqs.indexOf(':')) + "<br> ";
}
prop.put("reindexjobrunning_fieldlist", allfieldnames);
} else {
prop.put("reindexjobrunning_fieldlist", "");
}
}
if (post != null && post.containsKey("stopreindex")) {
sb.terminateThread("reindexSolr", false);
prop.put("infomessage", "reindex job stopped");
prop.put("showstartbutton", 1);
prop.put("reindexjobrunning",0);
} else {
prop.put("infomessage", "reindex is running");
prop.put("showstartbutton", 0);
}
} else {
if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) {
migration.reindexToschema(sb);
prop.put("showstartbutton", 0);
prop.put("querysize", "0");
prop.put("infomessage","reindex job started");
} else {
prop.put("showstartbutton", 1);
prop.put("reindexjobrunning", 0);
prop.put("querysize", "is empty");
prop.put("infomessage", "no reindex job running");
}
}
// return rewrite properties
return prop;
}

@ -175,6 +175,18 @@ import org.apache.solr.common.SolrInputDocument;
return querylist.isEmpty() ? "" : querylist.get(0);
}
/**
* @return copy of all Solr select queries in the queue or null if empty
*/
public String[] getQueryList() {
if (querylist != null) {
String[] list = new String[querylist.size()];
list = querylist.toArray(list);
return list;
}
return null;
}
/**
* @return number of currently selected (found) documents
*/

Loading…
Cancel
Save