In order to let you know about my problem I decided to use swt for the standalone app and to use Google Web Toolkit for web app!!!!
:):) bye ML 2009/5/27 N Hira <nh...@cognocys.com> > > Cool! > > 1. So you are creating a parser with { name, synonyms, propIn }, correct? > > 2. Sorry -- I meant the output of "query.toString()"; I'm expecting to see > something like this when the sentence parameter is set to philipcimiano: > name:philipcimiano synonyms:philipcimiano propIn:philipcimiano > > 3. Out of curiosity, what is the value of topDocs.totalHits for your > search? > > -h > > > > ----- Original Message ---- > From: Marco Lazzara <marco.lazz...@gmail.com> > To: java-user@lucene.apache.org > Sent: Wednesday, May 27, 2009 2:41:44 PM > Subject: Re: Searching index problems with tomcat > > I've made a bad copy-paste. this is the full class > > The output of philipcimiano is ex#pub1-author-ex#res2-name-philipcimiano > I've made a bad copy-paste. this is the full class > > public class RDFinder { > > private Analyzer analyzer; > private Directory directory; > private IndexSearcher isearcher; > private MultiFieldQueryParser parser; > private Query query; > private TreeMap<Integer,ArrayList<String>> resultingpaths; > private PrintWriter outFile; > > public RDFinder(String indexpath, String[] indexField) throws > CorruptIndexException, IOException{ > > //Creazione dell'oggetto per la ricerca indicando la struttura > (directory) su cui lavorare e l'analyzer > analyzer = new StandardAnalyzer(); > directory = FSDirectory.getDirectory(indexpath); > isearcher = new IndexSearcher(directory); > parser = new MultiFieldQueryParser(indexField, analyzer); > resultingpaths = new TreeMap<Integer,ArrayList<String>>(); > outFile = null; > > } > > public TreeMap<Integer,ArrayList<String>> Search(String sentence, String > Field) throws ParseException, IOException{ > query = parser.parse(sentence); > > try > { > > FileWriter fw = new FileWriter ("paths"); > BufferedWriter bw = new BufferedWriter (fw); > outFile = new PrintWriter (bw); > > } > catch (FileNotFoundException exception){} > catch (IOException exception){} > > //ArrayList<String> results = new ArrayList<String>(); > > //Effettua la ricerca ottenendo l'oggetto TopDocs > TopDocs topDocs = isearcher.search(query,1000); > //Stampa del conteggio numero di hits. > //System.out.println("Numero di hits " + topDocs.totalHits); > > //Array dei risultati > ScoreDoc[] scoreDocs = topDocs.scoreDocs; > for (ScoreDoc sc : scoreDocs) > { > //System.out.print(i++ + ": - "); > //Attraverso l'oggetto scoreDoc e' possibile ottenere un indice che > passato all metodo > //indexSearcher.doc restituisce un Document dal quale estrarre i > vari campi > > Field[] response = isearcher.doc(sc.doc).getFields(Field); > //System.out.println("Risultato "); > > for (int k = 0; k <response.length; k++){ > String res = response[k].stringValue(); > if (!res.trim().equals("")) > { > > outFile.println(res); > outFile.flush(); > res = res.toLowerCase(); > int lung = CountChar(res, '-')+1; > > //if (resultingpaths.containsKey(res.length())) > if (resultingpaths.containsKey(lung)) > //resultingpaths.get(res.length()).add(res); > resultingpaths.get(lung).add(res); > else { > ArrayList<String> respaths = new ArrayList<String>(); > respaths.add(res); > //resultingpaths.put(res.length(), respaths); > resultingpaths.put(lung, respaths); > } > //results.add(res); > > } > } > //codice che c'era prima > /*String res = isearcher.doc(sc.doc).get(Field); > System.out.println(res); > results.add(res);*/ > } > isearcher.close(); > return resultingpaths; > } > > public boolean Exists(String node) throws ParseException, IOException{ > > query = parser.parse(node); > > > > //Effettua la ricerca ottenendo l'oggetto TopDocs > TopDocs topDocs = isearcher.search(query,1); > > > //Array dei risultati > ScoreDoc[] scoreDocs = topDocs.scoreDocs; > > return (scoreDocs.length >= 1); > > } > > public String[] InputKeywords(String sentence){ > > QueryTermVector QTV = new QueryTermVector(sentence, analyzer); > return QTV.getTerms(); > > } > > public int CountChar(String s, char c){ > int count = 0; > for (int i = 0; i < s.length(); i++) > if (s.charAt(i) == c) count++; > return count; > } > > } > > [ message truncated by mai...@cognocys.com -- too many replies ] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >