(2) SOLR index data import: XML format

Source: Internet
Author: User
Tags solr

XML is the most common data index format. It not only indexes data, but also enhances documents and fields to change their importance.

The specific implementation method is as follows:

The field configuration of Schema. XML is as follows:

<field name="id" type="string" stored="true" indexed="true"/><field name="name" type="string" stored="true" indexed="true" omitNorms="false"/><field name="isbn" type="string" stored="true" indexed="true"/>


Here is the XML document that we will submit to SOLR as an index: Books. xml

<add overwrite="true" commitWithin="10000"><doc><field name="id">1</field><field name="isbn">ABC1234</field><field name="name" boost="2">Some Book</field></doc><doc boost="2.5"><field name="id">2</field><field name="isbn">ZYVW9821</field><field name="name" boost="2">Important Book</field></doc><doc><field name="id">3</field><field name="isbn">NXJS1234</field><field name="name" boost="2">Some other book</field></doc></add>

 

Note:

Overwrite = "true": tells SOLR to replace the document in XML if it already exists when indexing.

Commitwithin = "10000": tells SOLR to submit a document every 10000 (10 s) milliseconds during indexing.

Boost: used to indicate the importance of a document or field. The default value is 1.0. In this example, the boost value of the second document is 2.5, which indicates that it is more important than the other two documents.

Omitnorms = "false": Indicates whether to ignore the field specification. this parameter is set to No. If you want to specify the importance of a field during indexing, you must use the length specification of the field.

If it is set to true, these fields will not increase importance during indexing.

 

In Linux, we can submit the document using the following method:

curl http://localhost:8983/solr/update --data-binary @books.xml -H ‘Content-type:text/xml; charset=utf-8‘

 

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.