Note that there are some explanatory texts on larger screens.

plurals
  1. POsolrj xml output in a file
    primarykey
    data
    text
    <p>I set up a Solr Server on a TomCat-Servlet. In my Index there are about 610.000 Documents with several fields. My schema.xml:</p> <pre><code>&lt;field name="ID" type="myText" indexed="true" stored="true" required="true" /&gt; &lt;field name="text" type="myText" indexed="true" stored="false" multiValued="true" /&gt; &lt;dynamicField name="AT*" type="text_general" indexed="true" stored="true" multiValued="true" /&gt; </code></pre> <p>To search the Index with a given String (might be from another system) I created a little JavaProgram</p> <pre><code>class SolrjTest { public static void main(String[] args) throws IOException { SolrjTest solrj = new SolrjTest(); solrj.query(args[0]); } public void query(String q) throws IOException { CommonsHttpSolrServer server = null; String uuid = null; boolean flag = true; while(flag==true) { uuid = UUID.randomUUID().toString(); File f = new File("E:/dw-solr/tomcat-solr/bin/solr/data/SearchResult/"+uuid+".txt"); if(!f.exists()){ flag = false; } } try { server = new CommonsHttpSolrServer("http://localhost:8080/solr"); } catch(Exception e) { e.printStackTrace(); } SolrQuery query = new SolrQuery(); query.setQuery(q); FileWriter fw = new FileWriter("E:/dw-solr/tomcat-solr/bin/solr/data/SearchResult/"+uuid+".txt"); try { QueryResponse qr = server.query(query); SolrDocumentList sdl = qr.getResults(); Object[] o = new Object[sdl.size()]; o = sdl.toArray(); for (int i = 0; i &lt; o.length; i++) { System.out.println(o[i].toString()); fw.write(o[i].toString() + "\n"); } fw.flush(); fw.close(); System.out.println("finished"); } catch (SolrServerException e) { e.printStackTrace(); } } </code></pre> <p>And the results are saved in files. The problem is, that the format of the data is really strange. It looks like:</p> <p>"SolrDocument[{ID=0000000, AT_anyName=[anyValue, multiValue, justMoreValue], AT_anyName2=[Normal,Normal, Normal], AT_mightbeanothername=[couldbealoooooooooooooooongvalue, andanotherone, andanotherone]muchMoreStuff...about 20 - can differ from ID to ID}]"</p> <p>What I want to have, is a clear XML-format for this data. So I save it as a XML-file and send it back to the other System. The problem is, that the Method SolrDocumentList sdl = qr.getResults(); return the result as shown above. As I posted before, I have dynamicFields so stuff get really complicated (at least for me :-/ ). Is there any solution, how I can change the format to a plain, clear XML-format?</p> <p>Thanks a lot for any help.</p> <p>Best regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload