(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.