lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "m.harig" <m.ha...@gmail.com>
Subject Re: Searching doubt
Date Tue, 04 Aug 2009 07:29:26 GMT

Thanks for your reply, 

  my original code snippet is

                 IndexSearcher searcher = new IndexSearcher(indexDir);
		Analyzer analyzer = new StopAnalyzer();

		BooleanClause.Occur[] flags = { BooleanClause.Occur.SHOULD,
				BooleanClause.Occur.SHOULD, BooleanClause.Occur.SHOULD,
				BooleanClause.Occur.SHOULD, BooleanClause.Occur.SHOULD };

		// for multiple keyword search
		Query query = MultiFieldQueryParser.parse(qryStr, new String[] {
				"title", "path", "contents", "summary", "size" }, flags,
				analyzer);

		Hits hits = getHits(qryStr, searcher, query, "path");


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

			Document doc = hits.doc(inc);
				///////

		}
          

         // private method to get hits by using phrase query
	
	private Hits getHits(String qryStr, Searcher searcher, Query queryNorm,
			String phraseQryTerm) throws Exception {

		Hits hits = null;

		// for single word search
		PhraseQuery queryPhrase = new PhraseQuery();
		queryPhrase.setBoost(4.0f);
		queryPhrase.setSlop(1);
		queryPhrase.add(new Term(phraseQryTerm, qryStr.toLowerCase()));

		hits = searcher.search(queryPhrase);

		return hits;
	}


   if i use this code for my search , it gives me the unwanted search hits , 

      as i mentioned , if i search for "about us" , this is an example ,
there may be more number of urls like this ,  for example , "credit cards" ,
"book marks" , how do i handle it ?
-- 
View this message in context: http://www.nabble.com/Searching-doubt-tp24802552p24803560.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message