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‘