lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Harhen (JIRA)" <>
Subject [jira] Created: (LUCENE-495) Suggested Patches to MultiPhraseQuery and QueryTermExtractor (for use with HighLighter)
Date Thu, 09 Feb 2006 15:04:58 GMT
Suggested Patches to MultiPhraseQuery and QueryTermExtractor (for use with HighLighter)

         Key: LUCENE-495
     Project: Lucene - Java
        Type: Improvement
  Components: Search  
    Versions: 1.9    
 Environment: All
    Reporter: Michael Harhen

I encountered a problem with the Highlighter, where it was not recognizing MultiPhraseQuery.
To fix this, I developed the following two patches:

1. Addition to

Add the following method:

/** Returns the set of terms in this phrase. */
public Term[] getTerms() {
  ArrayList allTerms = new ArrayList();
  Iterator iterator = termArrays.iterator();
  while (iterator.hasNext()) {
    Term[] terms = (Term[]);
    for (int i = 0, n = terms.length; i < n; ++i) {
  return (Term[])allTerms.toArray(new Term[0]);

2. Patch to

a) Add the following import:

b) Add the following code to the end of the getTerms(...) method:
      else  if(query instanceof MultiPhraseQuery)
              getTermsFromMultiPhraseQuery((MultiPhraseQuery) query, terms, fieldName);

c) Add the following method:
 private static final void getTermsFromMultiPhraseQuery(MultiPhraseQuery query, HashSet terms,
String fieldName)
   Term[] queryTerms = query.getTerms();
   int i;

   for (i = 0; i < queryTerms.length; i++)
           terms.add(new WeightedTerm(query.getBoost(),queryTerms[i].text()));


Can the team update the repository?

Michael Harhen 

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message