Atomic update of SOLR/SOLRJ

Source: Internet
Author: User
Tags solr

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:
  1. /**
  2. * Atomic update mode
  3.  * */
  4. public  static  void  updatesolrfield () throws  exception{  
  5.      Solrinputdocument doc = new  solrinputdocument ();   
  6.      DOC  . AddField (" id ",  " ); span class= "comment" style= "padding:0px; margin:0px; Color:rgb (0,130,0); Width:auto; border:0px ">//uniquely identifies    by ID;
  7.     Map< string,string> map= new   Hashmap<string, string> ();   
  8.      Map.put (,  " new Field ""; //into a supported operation, for multi-range pipe  , add field 
  9. //map.put ("Set", "updated field");//For single-valued and multi-range Works, update field
  10. //map.put ("Inc", "100");//Put a supported operation on a numeric field
  11. Sd.addfield ("name", map);
  12. Server.add (SD);
  13. Server.commit ();
  14. System.out.println ("Atomic update succeeded!") ");
  15. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.