If I have individual files in the expected Solr format (having just ONE doc per file):
<add>
<doc>
<field name="id">GB18030TEST</field>
<field name="name">Test with some GB18030 encoded characters</field>
<field name="features">No accents here</field>
<field name="features">ÕâÊÇÒ»¸ö¹¦ÄÜ</field>
<field name="price">0</field>
</doc>
</add>
Is not there a way to easily marshal that file into a SolrInputDocument? Do I have to do the parsing myself?
EDIT: I need it in java pojo cause I want to modify some fields before indexing it with SolrJ...
This is best done programmatically. I know you're looking for a Java solution, but I'd personally recommend groovy.
The following script processes XML files found in the current directory.
EDIT: In order to convert XML to POJO, please reference this previous SO Question - Is there a library to convert Java POJOs to and from JSON and XML?
Since you already have your documents in the expected format, you can just use the post.jar or post.sh script file as shown in the Solr Tutorial - Indexing Data that both accept xml files as input.
Also, there is a toSolrInputDocument() method in the SolrJ ClientUtils library that may be useful for you. Granted you would need to marshal the files into the SolrDocument class in order to use the
toSolrInputDocument()
method.In Java you can do this.