Lucene itself does not have much of an introduction to atomic updates, but SOLR encapsulates them, and here's a simple introduction, which is useful for indexing. This is used in the code as follows:
- /**
- * Atomic update mode
- * */
- public static void updatesolrfield () throws exception{
- Solrinputdocument doc = new solrinputdocument ();
- DOC  . AddField (" id ", " ); span class= "comment" style= "padding:0px; margin:0px; Color:rgb (0,130,0); Width:auto; border:0px ">//uniquely identifies by ID;
- Map< string,string> map= new Hashmap<string, string> ();
- Map.put (, " new Field ""; //into a supported operation, for multi-range pipe , add field
- //map.put ("Set", "updated field");//For single-valued and multi-range Works, update field
- //map.put ("Inc", "100");//Put a supported operation on a numeric field
- Sd.addfield ("name", map);
- Server.add (SD);
- Server.commit ();
- System.out.println ("Atomic update succeeded!") ");
- }
note, of course, that the field of the operation must be stored (store= "true"), otherwise the updated index will overwrite the previous index.
Atomic update of SOLR/SOLRJ