Inline below On Jul 24, 2007, at 8:14 PM, Askar Zaidi wrote:
Sure. public float doBodySearch(Searcher searcher,String query, int id){ try{ score = search(searcher, query,id); } catch(IOException io){} catch(ParseException pe){} return score; }private float search(Searcher searcher, String queryString, int id) throwsParseException, IOException { // Build a Query object QueryParser queryParser = new QueryParser("contents", new KeywordAnalyzer()); queryParser.setDefaultOperator(QueryParser.Operator.AND); Query query = queryParser.parse(queryString); // Search for the query Hits hits = searcher.search(query); Document doc = null; // Examine the Hits object to see if there were any matches int hitCount = hits.length(); for(int i=0;i<hitCount;i++){ doc = hits.doc(i); String str = doc.get("item"); int tmp = Integer.parseInt(str); if(tmp==id) score = hits.score(i); }
Why do you need this if clause? Can't you make the id a required term in your query, that way you know it is a match in all returned documents? Also, do all three of your searches do this inner loop on the hits? You either need to implement caching, or, and this is better, I think, you need to refactor so that you can combine your various searches into a single search and only loop over the hits once. But, that is just a guess. I don't actually know what your application is doing. Also, if you are returning "score", why don't you break out of the hits loop after you find your hit?
In database land, I think you are doing the equivalent of the n- select problem (or whatever they call it, i.e. when you do a select, iterate over each select, generating a new select for each statement on other tables) and should try to figure out how to do a "join" instead, whereby a single query or two gets you all your results and then you process them.
-Grant --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
