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'