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> <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> <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"> <form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<table><tr valign="top"><td>
<fieldset> <fieldset>
<table> <table>
<tr> <tr>
<td>Documents in current queue</td> <td>Documents in current queue</td>
<td>#[querysize]#</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>
<tr> <tr>
<td>Documents processed</td> <td>Documents processed</td>
@ -34,12 +35,20 @@
<td></td> <td></td>
</tr> </tr>
</table> </table>
#(showstartbutton)# #(reindexjobrunning)#
<input type="submit" name="stopreindex" value="stop reindexing"/> <input type="submit" name="reindexnow" value="start reindex job now"/>
::<input type="submit" name="reindexnow" value="start reindex job now"/> ::<input type="submit" name="stopreindex" value="stop reindexing"/>
#(/showstartbutton)# #(/reindexjobrunning)#
<p class="info">#[infomessage]#</p> <p class="info">#[infomessage]#</p>
</fieldset> </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> </form>
#%env/templates/footer.template%# #%env/templates/footer.template%#
</body> </body>

@ -36,34 +36,49 @@ public class IndexReIndexMonitor_p {
prop.put("docsprocessed", "0"); prop.put("docsprocessed", "0");
prop.put("currentselectquery",""); prop.put("currentselectquery","");
BusyThread bt = sb.getThread("reindexSolr"); 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) { if (bt != null) {
prop.put("reindexjobrunning", 1);
prop.put("querysize", bt.getJobCount()); prop.put("querysize", bt.getJobCount());
if (bt instanceof ReindexSolrBusyThread) { if (bt instanceof ReindexSolrBusyThread) {
prop.put("docsprocessed", ((ReindexSolrBusyThread) bt).getProcessed()); prop.put("docsprocessed", ((ReindexSolrBusyThread) bt).getProcessed());
prop.put("currentselectquery","q="+((ReindexSolrBusyThread) bt).getCurrentQuery()); 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")) { if (post != null && post.containsKey("stopreindex")) {
sb.terminateThread("reindexSolr", false); sb.terminateThread("reindexSolr", false);
prop.put("infomessage", "reindex job stopped"); prop.put("infomessage", "reindex job stopped");
prop.put("showstartbutton", 1); prop.put("reindexjobrunning",0);
} else { } else {
prop.put("infomessage", "reindex is running"); prop.put("infomessage", "reindex is running");
prop.put("showstartbutton", 0);
} }
} else { } else {
if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) { prop.put("reindexjobrunning", 0);
migration.reindexToschema(sb);
prop.put("showstartbutton", 0);
prop.put("querysize", "0");
prop.put("infomessage","reindex job started");
} else {
prop.put("showstartbutton", 1);
prop.put("querysize", "is empty"); prop.put("querysize", "is empty");
prop.put("infomessage", "no reindex job running"); prop.put("infomessage", "no reindex job running");
} }
}
// return rewrite properties // return rewrite properties
return prop; return prop;
} }

@ -175,6 +175,18 @@ import org.apache.solr.common.SolrInputDocument;
return querylist.isEmpty() ? "" : querylist.get(0); 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 * @return number of currently selected (found) documents
*/ */

Loading…
Cancel
Save