Lucene's UpdateDocument

Source: Internet
Author: User

Lucene Fundamentally, does not support the document update operation, it provides the UpdateDocument method is actually first deleted after the new. In the actual use of the process, found that the method has the following limitations:

1, the set of the term corresponding field must be a string type

That is, the following combinations can perform normally:

Document document = new document ();d ocument. ADD (New Field ("Serviceid", serviceQueryResult.ServiceId.ToString (), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_ norms));d ocument. ADD (New Numericfield ("Shopid", Field.Store.YES, True). Setintvalue (servicequeryresult.shopid));d ocument. ADD (New Field ("ServiceName", Servicequeryresult.servicename, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); Writer. Adddocument (document); writer. UpdateDocument (New term ("Serviceid", ServiceQueryResult.ServiceId.ToString ()), document);
If Serviceid is an integer type, it cannot be updated directly with the UpdateDocument method and must be created after deletion, as follows:

Document document = new document ();d ocument. ADD (New Numericfield ("Serviceid", Field.Store.YES, True). Setintvalue (Servicequeryresult.serviceid));d ocument. ADD (New Numericfield ("Shopid", Field.Store.YES, True). Setintvalue (servicequeryresult.shopid));d ocument. ADD (New Field ("ServiceName", Servicequeryresult.servicename, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); Writer. Adddocument (document); writer. Deletedocuments (Numericrangequery.newintrange ("Serviceid", Servicequeryresult.serviceid, Servicequeryresult.serviceid, True, true); writer. Adddocument (document);




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Lucene's UpdateDocument

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.