Hello,

I'm using tomcat to run my servlet. This is the code of processReuqest method:

response.setContentType("text/xml;charset=UTF-8");

       PrintWriter outResponse = response.getWriter();

       StringBuffer out = new StringBuffer();

       try {

           String search = request.getParameter("q");

           // Lucene properties

           String index = "/tmp/index/";

           
org.apache.lucene.search.BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);

           IndexReader id = IndexReader.open(index);

           IndexSearcher is = new IndexSearcher(id);

           Analyzer analyzer = new StandardAnalyzer();

           QueryParser parser = new QueryParser("all", analyzer);

           Query query = parser.parse(search);

           Hits hits = is.search(query);

           out.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

out.append("<response>"); out.append("<result name=\"response\">");
           long startTime =0;

           long alltime = 0;

           for(int i=0;i<hits.length();i++){

out.append("<doc><str name=\"id\">");
               startTime = System.currentTimeMillis();

               String s = hits.doc(i).get("id");

               alltime += (System.currentTimeMillis() - startTime);

out.append(s);
               out.append("</str></doc>");

}
           System.out.println("Time: " + alltime + "ms");

           out.append("</result>");

           out.append("</response>");

           startTime = System.currentTimeMillis();

           outResponse.print(out.toString());

           System.out.println(System.currentTimeMillis()-startTime);

} finally {
           long startTime = System.currentTimeMillis();

           outResponse.close();

           System.out.println(System.currentTimeMillis()-startTime);

       }

}

I'm getting documents from lucene and creating a string with all the results with string buffer. The string creation takes 2 seconds and the

outResponse.print(out.toString());

takes 1 second. Closing the writer take no time at all, although I have to wait 2 minutes until the result shows in firefox. The same happens with solr, that should make something like that. The xml file, only has 300KB. Why I need to wait for so long?

Thank you.

--
Bruno Matos
Analista de Sistemas PardigmaXis - Engenharia e Arquitectura de Software, S.A
Avenida da Boavista, 1043
4100-129 Porto
Portugal

Tel: (+351) 22 605 48 72
Fax: (+351) 22 605 48 74


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to