Solr支持簡單的原子更新(也被稱爲部分更新)單文件經過字段修飾符如ADD,Inc.樂觀併發控制是自動更新文件的一種方法。java
Solr支持整個doc 更新幾個字段,自動更新文檔中的值。express
set – set or replace a particular value, or remove the value if null is specified as the new valueadd – adds an additional value to a list併發
remove – removes a value (or a list of values) from a listcode
removeregex – removes from a list that match the given Java regular expressionserver
inc – increments a numeric value by a specific amount (use a negative value to decrement)ci
// create the SolrJ client HttpSolrClient client = newHttpSolrClient("http://localhost:8983/solr"); // create the document SolrInputDocument sdoc = newSolrInputDocument(); sdoc.addField("id","book1"); Map<String,Object> fieldModifier = newHashMap<>(1); fieldModifier.put("add","Cyberpunk"); sdoc.addField("cat", fieldModifier); // add the map as the field value client.add( sdoc ); // send it to the solr server client.close(); // shutdown client before we exit