I don't know what your application is, and I have no experience with the Highlighter code, so forgive me if this is a silly suggestion:
It looks like you are building a query up programaticaly, which contains some words to search on, and some other stuff that's mainly being used to "filter" the results (i'll avoid my usual rant about people underutilizing Filters). So why not pass the Higherlighter just the portion of the Query that you acctaully want to contribute to the highlighting? In this query... : >> +DocumentType:news : >> +(CompanyId:10 CompanyId:20 CompanyId:30 CompanyId:40) : >> +FilingDate:[20041201 TO 20051201] : >> +(Content:"cost saving" Content:"cost savings" : >>Content:outsource : >>Content:outsources Content:downsize : >>Content:downsizes : >>Content:restructuring Content:restructure) ...just give the highlighter... (Content:"cost saving" Content:"cost savings" Content:outsource Content:outsources Content:downsize Content:downsizes Content:restructuring Content:restructure) : Date: Thu, 01 Dec 2005 10:38:41 +0530 : From: Harini Raghavan <[EMAIL PROTECTED]> : Reply-To: java-user@lucene.apache.org : To: java-user@lucene.apache.org : Subject: Re: how to control terms to be highlighted? : : Hi Mark, : : It would be great if you can make this change and send the : QueryTermsExtractor class. I am invoking the QueryScorer(Query) : contructor. Should I use QueryScorer(Query query, IndexReader reader, : String fieldName) instead for this to work? : : Thanks, : Harini : : mark harwood wrote: : : >>>>Is there anyway to restrict the highlighter to : >>>> : >>>> : >>highlight only the values : >>mentioned for the field 'Content'? : >> : >> : > : >The problem lies in the QueryTermsExtractor class : >which is typically used to provide the Highlighter : >with the list of strings to identify in the text. It : >currently has no filter for fieldname - you could add : >this without too much effort. : > : >I could make this modification but it may change the : >behaviour of existing applications - currently the : >QueryTermsExtractor method that takes a fieldname only : >uses that fieldname to derive IDF weightings, the : >proposed change would also have the effect of : >filtering out any query terms that weren't for this : >field. : >Would this change be a problem for anyone? : > : >Cheers, : >Mark : > : >--- Harini Raghavan <[EMAIL PROTECTED]> : >wrote: : > : > : > : >>Hi, : >> : >>I have a requirement to highlight search keywords in : >>the results and : >>display the matching fragment of the text with the : >>results. I am using : >>the Hits highlighting mentioned in Lucene in Action. : >> : >>Here is the search query(BooleanQuery) I am passing : >>to the IndexSearcher : >>and QueryScorer: : >> +DocumentType:news : >> +(CompanyId:10 CompanyId:20 CompanyId:30 : >>CompanyId:40) : >> +FilingDate:[20041201 TO 20051201] : >> +(Content:"cost saving" Content:"cost savings" : >>Content:outsource : >>Content:outsources Content:downsize : >>Content:downsizes : >>Content:restructuring Content:restructure) : >> : >>My requirement is to highlight only the keywords for : >>'Content' field, : >>but the highlighter api is also highlighting words : >>like 'news', '10', : >>'40' etc. : >>Is there anyway to restrict the highlighter to : >>highlight only the values : >>mentioned for the field 'Content'? : >> : >>Thanks, : >>Harini : >> : >> : >> : >> : >> : >> : >> : >> : >--------------------------------------------------------------------- : > : > : >>To unsubscribe, e-mail: : >>[EMAIL PROTECTED] : >>For additional commands, e-mail: : >>[EMAIL PROTECTED] : >> : >> : >> : >> : > : > : > : > : >___________________________________________________________ : >Yahoo! Model Search 2005 - Find the next catwalk superstars - http://uk.news.yahoo.com/hot/model-search/ : > : >--------------------------------------------------------------------- : >To unsubscribe, e-mail: [EMAIL PROTECTED] : >For additional commands, e-mail: [EMAIL PROTECTED] : > : > : > : > : : : --------------------------------------------------------------------- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]