I have written really hardcoded solution for my problem but it should be ok. I need to edit some values of concrete fields for all docs in my index. I have 55500 docs in my index.
I am trying to edit fields for every document and commit by 500 docs. I think this solution should work (I tried to remove one document by id from my index and it was deleted) but there is no change in my index... there are still fields with bad values (with #0; which I want to remove)
for (int i = 0; i < 55501; i = i + 500) {
SolrQuery query = new SolrQuery();
query.setParam("start", i+"");
query.setParam("q", "*:*");
query.setParam("rows", "500");
String url = "http://MYINDEX";
HttpSolrServer solrServer = new HttpSolrServer(url);
QueryResponse qResponse;
try {
qResponse = solrServer.query(query);
SolrDocumentList docs=qResponse.getResults();
for (SolrDocument solrDocument : docs) {
String parseTime = (String) solrDocument.getFieldValue("parse_time");
String parseTimeUnix = (String) solrDocument.getFieldValue("parse_time_unix_timestamp");
parseTime = parseTime.replaceAll("#0;", "");
parseTimeUnix = parseTimeUnix.replaceAll("#0;", "");
solrDocument.setField("parse_time", parseTime);
solrDocument.setField("parse_time_unix_timestamp", parseTimeUnix);
}
} catch (SolrServerException e) {
e.printStackTrace();
}
try {
solrServer.commit();
} catch (SolrServerException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}