java - SolrJ - I cannot update a values of concrete fields of all Solr docs -


i have written hardcoded solution problem should ok. need edit values of concrete fields docs in index. have 55500 docs in index.

i trying edit fields every document , commit 500 docs. think solution should work (i tried remove 1 document id index , deleted) there no change in index... there still fields bad values (with #0; want remove)

    (int = 0; < 55501; = + 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();             (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();         }                } 

you need send updated documents solr them updated.

use add command solrserver.add(docs); before call commit have send them back. see updated snippet below.

 ...  try {      solrserver.add(docs);      solrserver.commit();  }  ... 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -